﻿/*
    Original Author: Zuoyuan Wang
    Copyright (c) 2024 Zuoyuan Wang
*/
/*
#include "wstd/polynomial.h"

namespace wgp {


    const double bezier_standard_fitting_matrix_2d[3][3] = {
        { 1, 0, 0 },
        { -0.5, 2, -0.5 },
        { 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_3d[4][4] = {
        { 1, 0, 0, 0 },
        { -0.8333333333333333, 3, -1.5, 0.3333333333333333 },
        { 0.3333333333333333, -1.5, 3, -0.8333333333333334 },
        { 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_4d[5][5] = {
        { 1, 0, 0, 0, 0 },
        { -1.0833333333333333, 4, -2.999999999999999, 1.3333333333333333, -0.24999999999999992 },
        { 0.7222222222222222, -3.5555555555555554, 6.666666666666666, -3.5555555555555554, 0.7222222222222221 },
        { -0.25, 1.3333333333333333, -3, 4, -1.0833333333333333 },
        { 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_5d[6][6] = {
        { 1, 0, 0, 0, 0, 0 },
        { -1.2833333333333332, 4.999999999999999, -4.999999999999999, 3.333333333333332, -1.249999999999999, 0.1999999999999998 },
        { 1.1208333333333331, -6.041666666666664, 12.291666666666663, -9.583333333333329, 3.854166666666664, -0.641666666666666 },
        { -0.6416666666666665, 3.8541666666666643, -9.583333333333329, 12.29166666666666, -6.041666666666663, 1.1208333333333327 },
        { 0.1999999999999999, -1.2499999999999991, 3.333333333333331, -4.999999999999997, 4.999999999999998, -1.283333333333333 },
        { 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_6d[7][7] = {
        { 1, 0, 0, 0, 0, 0, 0 },
        { -1.45, 6.000000000000001, -7.499999999999999, 6.666666666666668, -3.7499999999999982, 1.1999999999999995, -0.1666666666666667 },
        { 1.5133333333333339, -8.880000000000003, 20.1, -20.533333333333342, 12.299999999999999, -4.079999999999999, 0.5800000000000003 },
        { -1.1350000000000007, 7.560000000000004, -20.925000000000004, 30.000000000000014, -20.925000000000004, 7.560000000000002, -1.135000000000001 },
        { 0.5800000000000004, -4.080000000000003, 12.300000000000004, -20.533333333333342, 20.10000000000001, -8.880000000000004, 1.5133333333333343 },
        { -0.1666666666666668, 1.2000000000000008, -3.7500000000000018, 6.66666666666667, -7.5000000000000036, 6.000000000000002, -1.4500000000000004 },
        { 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_7d[8][8] = {
        { 1, 0, 0, 0, 0, 0, 0, 0 },
        { -1.5928571428571432, 7, -10.5, 11.66666666666665, -8.749999999999975, 4.199999999999988, -1.1666666666666652, 0.14285714285714313 },
        { 1.8939153439153449, -12.016666666666664, 30.27499999999999, -38.17592592592587, 30.333333333333254, -15.049999999999962, 4.27129629629629, -0.5309523809523818 },
        { -1.7016269841269853, 12.421111111111104, -38.109166666666646, 62.261111111111006, -55.951388888888765, 29.796666666666603, -8.853055555555544, 1.136349206349208 },
        { 1.136349206349207, -8.853055555555551, 29.79666666666664, -55.9513888888888, 62.261111111111006, -38.10916666666661, 12.4211111111111, -1.701626984126986 },
        { -0.5309523809523814, 4.271296296296296, -15.049999999999986, 30.333333333333297, -38.17592592592588, 30.274999999999977, -12.016666666666664, 1.8939153439153453 },
        { 0.142857142857143, -1.1666666666666672, 4.199999999999997, -8.749999999999991, 11.666666666666655, -10.499999999999995, 7, -1.5928571428571432 },
        { 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_8d[9][9] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -1.7178571428571414, 7.999999999999989, -13.999999999999977, 18.666666666666625, -17.499999999999968, 11.199999999999992, -4.666666666666667, 1.1428571428571421, -0.12500000000000097 },
        { 2.2606575963718774, -15.412244897959148, 42.9714285714285, -64.40634920634908, 63.714285714285595, -42.05714285714283, 17.87936507936508, -4.44081632653061, 0.4908163265306157 },
        { -2.3215986394557735, 18.398185941043018, -62.13968253968239, 115.12380952380931, -126.38888888888866, 88.66031746031742, -39.21904761904762, 10.017233560090698, -1.1303287981859476 },
        { 1.8572789115646162, -15.83600907029471, 58.879999999999825, -123.85523809523788, 158.90793650793628, -123.85523809523806, 58.88000000000001, -15.83600907029478, 1.8572789115646333 },
        { -1.130328798185934, 10.017233560090649, -39.21904761904749, 88.6603174603173, -126.38888888888874, 115.12380952380948, -62.13968253968254, 18.398185941043078, -2.321598639455787 },
        { 0.49081632653060886, -4.4408163265305864, 17.879365079365012, -42.05714285714278, 63.714285714285644, -64.40634920634918, 42.97142857142856, -15.412244897959177, 2.260657596371883 },
        { -0.12499999999999908, 1.1428571428571357, -4.666666666666648, 11.199999999999976, -17.49999999999998, 18.666666666666654, -13.999999999999995, 7.999999999999997, -1.7178571428571427 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_9d[10][10] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -1.8289682539682524, 8.999999999999982, -17.99999999999992, 27.999999999999808, -31.499999999999666, 25.19999999999968, -13.999999999999819, 5.1428571428570935, -1.1249999999999796, 0.11111111111110972 },
        { 2.613268849206343, -19.03660714285707, 58.32321428571396, -101.22499999999926, 119.78437499999865, -98.66249999999876, 55.862499999999265, -20.796428571428354, 4.594419642857063, -0.4572420634920574 },
        { -2.98068664965985, 25.449394132652884, -93.95070153061147, 195.46874999999824, -253.34196428571119, 220.18258928571146, -129.14598214285544, 49.29221938775455, -11.09359056122431, 1.119972363945563 },
        { 2.7285306831065532, -25.226977040816056, 102.69585459183557, -240.13035714285442, 352.2314732142811, -333.24910714285284, 207.3290178571403, -82.58647959183583, 19.195169005101775, -1.9871244331065525 },
        { -1.9871244331065518, 19.195169005101764, -82.58647959183557, 207.32901785714, -333.24910714285255, 352.2314732142813, -240.13035714285454, 102.69585459183575, -25.22697704081607, 2.728530683106553 },
        { 1.1199723639455614, -11.093590561224302, 49.29221938775431, -129.14598214285516, 220.1825892857112, -253.3419642857113, 195.46874999999824, -93.95070153061157, 25.4493941326529, -2.9806866496598494 },
        { -0.45724206349205576, 4.594419642857057, -20.796428571428205, 55.86249999999909, -98.6624999999986, 119.78437499999865, -101.22499999999918, 58.32321428571397, -19.036607142857072, 2.613268849206343 },
        { 0.11111111111110909, -1.1249999999999778, 5.142857142857047, -13.999999999999762, 25.199999999999637, -31.49999999999965, 27.999999999999787, -17.99999999999992, 8.999999999999982, -1.8289682539682526 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_10d[11][11] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -1.9289682539682715, 10.000000000000155, -22.500000000000608, 40.00000000000154, -52.50000000000241, 50.400000000002656, -35.00000000000218, 17.142857142858432, -5.625000000000521, 1.1111111111112275, -0.1000000000000125 },
        { 2.9521604938272277, -22.865961199295132, 76.4484126984151, -150.7231040564435, 207.54629629630602, -204.84444444445526, 144.84567901235462, -71.85185185185712, 23.79960317460527, -4.735449735450216, 0.42865961199299685 },
        { -3.6685534244563502, 33.53339947090081, -134.41592261905308, 310.94135802470527, -464.4618055555782, 481.1416666666922, -351.25964506174967, 178.2341269841395, -60.04092261905251, 12.10335831863725, -1.107060185185309 },
        { 3.735726883346155, -37.1741412614449, 164.43476001512568, -423.93801965232717, 702.455908289278, -781.6052910053327, 599.8974867725216, -315.7193247669644, 109.34051398337911, -22.523935500127887, 2.0963162425466075 },
        { -3.113105736121854, 32.50451415134183, -152.3329239103145, 420.9183673469636, -756.3106261023348, 917.6675485009312, -756.3106261023343, 420.91836734696346, -152.33292391031443, 32.50451415134186, -3.1131057361218613 },
        { 2.096316242546601, -22.523935500127866, 109.3405139833792, -315.71932476696475, 599.8974867725228, -781.6052910053342, 702.4559082892785, -423.93801965232734, 164.43476001512573, -37.17414126144493, 3.7357268833461608 },
        { -1.107060185185306, 12.103358318637252, -60.04092261905261, 178.23412698414, -351.2596450617511, 481.14166666669416, -464.46180555557925, 310.9413580247056, -134.41592261905325, 33.53339947090084, -3.668553424456355 },
        { 0.4286596119929966, -4.7354497354502305, 23.799603174605327, -71.8518518518575, 144.84567901235562, -204.84444444445657, 207.5462962963068, -150.72310405644376, 76.44841269841523, -22.86596119929515, 2.9521604938272303 },
        { -0.10000000000001265, 1.1111111111112335, -5.625000000000535, 17.142857142858556, -35.000000000002494, 50.400000000003054, -52.50000000000265, 40.000000000001606, -22.500000000000643, 10.000000000000156, -1.928968253968272 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_11d[12][12] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.019877344877336, 10.999999999999883, -27.4999999999992, 54.99999999999731, -82.49999999999359, 92.399999999991, -76.99999999999147, 47.1428571428502, -20.624999999997037, 6.11111111111011, -1.0999999999997663, 0.09090909090906842 },
        { 3.2780349927849555, -26.881031746031233, 97.4525793650759, -215.07182539681392, 337.7327380952112, -388.4246666666283, 329.33388888885185, -204.10238095235178, 90.10505952379674, -26.884523809519486, 4.866103174602181, -0.4039754689753722 },
        { -4.377552596066388, 42.61063888888754, -184.35632605819222, 469.8954343033222, -794.5948214285052, 955.228388888793, -834.0169104937327, 527.7551190475473, -236.6382638888563, 71.4608193709472, -13.059204365076875, 1.0926783309280856 },
        { 4.865337199708545, -51.7887376175754, 247.30309652408744, -697.6824145722586, 1291.0440217150513, -1651.5351959874852, 1506.386478394894, -984.2496748235088, 452.2089481370665, -139.19431565988594, 25.83123298794385, -2.1887762980328054 },
        { -4.512819992369588, 50.5845892778373, -256.3575489667103, 773.6018335458491, -1539.9760505242245, 2116.633210427469, -2046.8703877312626, 1400.4260546578141, -667.3178725945612, 211.51907734155805, -40.20532629833761, 3.4752408569342306 },
        { 3.475240856934539, -40.205326298339834, 211.51907734156325, -667.3178725945702, 1400.426054657825, -2046.8703877312653, 2116.6332104274743, -1539.9760505242207, 773.6018335458402, -256.35754896670517, 50.584589277835086, -4.5128199923692796 },
        { -2.1887762980330367, 25.831232987945516, -139.1943156598897, 452.20894813707287, -984.2496748235221, 1506.3864783949023, -1651.5351959874945, 1291.044021715053, -697.6824145722526, 247.30309652408388, -51.788737617573766, 4.865337199708316 },
        { 1.0926783309282142, -13.059204365077814, 71.46081937094918, -236.63826388885968, 527.7551190475575, -834.0169104937395, 955.2283888888011, -794.5948214285089, 469.8954343033195, -184.35632605819046, 42.610638888886676, -4.3775525960662645 },
        { -0.4039754689754225, 4.866103174602561, -26.88452380952023, 90.10505952379802, -204.1023809523568, 329.3338888888547, -388.42466666663256, 337.7327380952139, -215.07182539681335, 97.45257936507532, -26.88103174603091, 3.2780349927849093 },
        { 0.09090909090908005, -1.0999999999998569, 6.111111111110278, -20.624999999997325, 47.14285714285155, -76.99999999999208, 92.39999999999215, -82.49999999999446, 54.999999999997264, -27.499999999999083, 10.999999999999812, -2.019877344877326 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_12d[13][13] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.1032106782107145, 12.000000000000366, -33.00000000000166, 73.33333333333783, -123.75000000000799, 158.4000000000112, -154.0000000000114, 113.14285714286689, -61.8750000000047, 24.444444444447168, -6.600000000000593, 1.0909090909092212, -0.08333333333334614 },
        { 3.591694870785932, -31.06587957497203, 121.43116883117571, -296.5137085137273, 522.866883116916, -686.549610389657, 678.678787878835, -504.4987012987411, 278.30844155846205, -110.68975468976608, 30.04623376623639, -4.987957497048978, 0.38240194149290635 },
        { -5.101937032664677, 52.64381582054687, -244.54659740261394, 681.3451082251532, -1286.3799350650131, 1759.7772467533573, -1787.6320000001108, 1354.841766233859, -758.3037662338185, 305.00017316020103, -83.53589610390308, 13.969530106258878, -1.0775084612358787 },
        { 6.105022519568613, -69.15420385675573, 354.5040346320627, -1086.9641173641924, 2223.8296103897405, -3215.143896104076, 3395.8878383840192, -2648.5460779222294, 1515.1272727273658, -619.956209716259, 172.16277056278417, -29.11957182212015, 2.2675275700732964 },
        { -6.185934890026622, 74.01687524597429, -403.16796536800086, 1319.7046657047583, -2886.437012987174, 4439.515844156057, -4928.87111111133, 3998.161038961223, -2359.6347402598644, 990.0965848966516, -280.67826839828876, 48.2956631247583, -3.815639074730377 },
        { 5.302229905737215, -65.64771124979708, 371.82033395179656, -1272.4360338075494, 2925.6336734695374, -4751.059591836923, 5573.774199134396, -4751.0595918369045, 2925.6336734695133, -1272.4360338075328, 371.8203339517858, -65.6477112497941, 5.302229905736844 },
        { -3.81563907473061, 48.29566312475998, -280.6782683982933, 990.0965848966468, -2359.6347402598426, 3998.1610389611615, -4928.871111111241, 4439.515844155962, -2886.4370129871086, 1319.704665704723, -403.1679653679855, 74.01687524597048, -6.1859348900261875 },
        { 2.267527570073397, -29.11957182212071, 172.16277056278443, -619.9562097162425, 1515.1272727273229, -2648.5460779221335, 3395.8878383838965, -3215.1438961039557, 2223.8296103896646, -1086.9641173641526, 354.5040346320477, -69.15420385675215, 6.1050225195682275 },
        { -1.0775084612359043, 13.969530106258894, -83.53589610390192, 305.0001731601858, -758.303766233783, 1354.8417662337815, -1787.632000000015, 1759.7772467532668, -1286.3799350649572, 681.345108225124, -244.54659740260368, 52.643815820544454, -5.101937032664425 },
        { 0.38240194149290785, -4.987957497048896, 30.04623376623553, -110.68975468975808, 278.30844155844494, -504.4987012987026, 678.6787878787885, -686.549610389614, 522.8668831168892, -296.5137085137135, 121.43116883117096, -31.065879574970946, 3.5916948707858194 },
        { -0.0833333333333452, 1.090909090909189, -6.600000000000331, 24.44444444444499, -61.87500000000029, 113.1428571428567, -153.9999999999993, 158.40000000000012, -123.75000000000097, 73.33333333333427, -33.000000000000426, 12.000000000000094, -2.103210678210686 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_13d[14][14] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.1801337551337854, 13.000000000000451, -39.00000000000355, 95.3333333333472, -178.75000000003809, 257.4000000000734, -286.0000000000971, 245.14285714295534, -160.87500000007373, 79.44444444448082, -28.600000000014347, 7.090909090912165, -1.0833333333337256, 0.0769230769230869 },
        { 3.893952467285952, -35.40710076960296, 148.47130230881874, -397.35577601417367, 777.316385582186, -1147.2205952384325, 1295.3451058205537, -1122.942063492516, 743.1550595241497, -369.3808421518435, 133.66562169318723, -33.27990620492025, 5.102212101172176, -0.3633556258556722 },
        { -5.837326467549462, 63.598024837122225, -315.72047405881557, 954.9234102935911, -1990.802775899358, 3053.015670996605, -3536.3125408862893, 3121.8950360762933, -2094.3389806557093, 1052.0231762069789, -383.91050204443195, 96.24565263023653, -14.840358065234804, 1.0619870365326163 },
        { 7.443700466703666, -89.33274998817096, 489.2247646897398, -1620.5260937887829, 3634.0724532788095, -5859.214700849638, 7030.992736795054, -6370.726206952984, 4359.630711266339, -2224.438080491704, 822.0579320089339, -208.2384630122316, 32.388927165026914, -2.3349305870198265 },
        { -8.128856277855082, 103.32909945272566, -601.7888504585974, 2124.1513698739923, -5067.019966460023, 8629.648322405155, -10818.251930897963, 10145.215299170613, -7134.888816119633, 3721.694044201369, -1400.528029954694, 360.17350238456635, -56.740576467962384, 4.135389148168411 },
        { 7.61397879366315, -100.37063814362308, 608.6185915128603, -2245.3934855819775, 5616.476138349695, -10045.006170835723, 13201.34529126686, -12907.203648364155, 9405.885966020667, -5055.911910489126, 1951.6127663403802, -512.8849950665697, 82.31475840559214, -6.096642208390213 },
        { -6.096642208392186, 82.31475840560816, -512.8849950666242, 1951.6127663404532, -5055.911910489198, 9405.88596602053, -12907.203648364039, 13201.345291266625, -10045.006170835557, 5616.476138349471, -2245.393485581835, 608.6185915127862, -100.37063814360364, 7.613978793660912 },
        { 4.13538914816982, -56.74057646797275, 360.1735023845969, -1400.528029954704, 3721.6940442013265, -7134.88881611932, 10145.215299170257, -10818.25193089752, 8629.648322404782, -5067.019966459723, 2124.151369873825, -601.788850458522, 103.32909945270737, -8.128856277853078 },
        { -2.334930587020653, 32.388927165032264, -208.23846301224484, 822.0579320089175, -2224.438080491636, 4359.630711266052, -6370.726206952627, 7030.992736794652, -5859.214700849273, 3634.072453278558, -1620.526093788649, 489.22476468968335, -89.33274998815791, 7.443700466702282 },
        { 1.061987036533006, -14.840358065237004, 96.24565263024117, -383.9105020444167, 1052.0231762069354, -2094.3389806555433, 3121.8950360760755, -3536.312540886053, 3053.0156709963812, -1990.802775899213, 954.9234102935155, -315.72047405878476, 63.59802483711533, -5.837326467548746 },
        { -0.3633556258558109, 5.102212101172866, -33.2799062049216, 133.66562169318044, -369.38084215182704, 743.1550595240868, -1122.942063492431, 1295.3451058204619, -1147.2205952383429, 777.3163855821286, -397.3557760141444, 148.47130230880688, -35.40710076960041, 3.8939524672856907 },
        { 0.07692307692311728, -1.083333333333863, 7.090909090912439, -28.600000000012756, 79.4444444444773, -160.87500000005997, 245.1428571429365, -286.00000000007657, 257.40000000005296, -178.750000000025, 95.33333333334059, -39.00000000000087, 12.999999999999893, -2.180133755133729 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_14d[15][15] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.2515623265622877, 13.999999999999686, -45.499999999999076, 121.33333333333447, -250.25000000001486, 400.40000000006575, -500.5000000001073, 490.28571428587486, -375.3750000001787, 222.44444444458307, -100.10000000008552, 33.09090909093926, -7.583333333342714, 1.0769230769247857, -0.07142857142869366 },
        { 4.185587973280083, -39.8932640009546, 178.6531080031026, -519.9638435638464, 1117.3420940171545, -1830.867350427636, 2324.5175213680177, -2302.2212454219903, 1777.0756410264735, -1059.736182336834, 479.27683760723664, -159.08655788670256, 36.58107355611822, -5.20981411751452, 0.3463942040870957 },
        { -6.580342299556414, 75.44070268762007, -398.5752227402031, 1300.8461693861666, -2967.713057336324, 5041.7926780634125, -6557.2645584059555, 6606.9136507957555, -5165.8761164553525, 3111.5271889857268, -1418.4930626791977, 473.9203781408052, -109.56826939277495, 15.676258243204803, -1.046396993321786 },
        { 8.871489794485623, -112.37016573600295, 654.6278939550398, -2330.1959388235814, 5685.435128421198, -10113.28726323197, 13587.432393381121, -14022.020324864718, 11166.158829971258, -6823.280728370249, 3147.016172194391, -1061.5425859223083, 247.40059245029386, -35.63834496424613, 2.392851745297208 },
        { -10.335845239285735, 138.99992257560075, -861.6858176787601, 3262.8261109409523, -8433.838336966819, 15763.053059082833, -22022.97623273798, 23435.942812256646, -19123.63881000979, 11918.539573231717, -5586.8496645626365, 1910.2038288626024, -450.3115338869991, 65.50667902913375, -4.435744897249935 },
        { 10.439601485041331, -145.88444894488094, 942.5456742355117, -3728.973359791254, 10084.69196895377, -19710.07904467505, 28706.199520927403, -31672.865940159725, 26649.81439085638, -17044.472037093772, 8166.609101682046, -2844.900354719182, 681.5135426162194, -100.5291788653185, 6.890563492867687 },
        { -9.134651299410134, 130.95604793673854, -870.408087989537, 3552.9381446072834, -9942.987145412535, 20161.826828639918, -30515.93554726104, 34986.48882155874, -30515.935547266337, 20161.826828647256, -9942.987145418194, 3552.9381446100424, -870.4080879904401, 130.95604793691024, -9.134651299424279 },
        { 6.8905634928548976, -100.52917886516155, 681.5135426153898, -2844.900354716637, 8166.60910167673, -17044.472037086703, 26649.814390850923, -31672.865940159096, 28706.19952093157, -19710.079044681235, 10084.691968958708, -3728.9733597936943, 942.5456742363181, -145.88444894503502, 10.439601485054173 },
        { -4.435744897240527, 65.50667902901704, -450.31153388638126, 1910.2038288607137, -5586.849664558591, 11918.539573226275, -19123.63881000538, 23435.94281225583, -22022.976232740755, 15763.053059087124, -8433.838336970379, 3262.8261109427276, -861.685817679352, 138.9999225757145, -10.335845239295322 },
        { 2.3928517452916536, -35.63834496417647, 247.40059244992653, -1061.5425859211962, 3147.0161721919344, -6823.280728366954, 11166.15882996851, -14022.020324864152, 13587.432393382738, -10113.287263234426, 5685.435128423311, -2330.1959388246387, 654.6278939553939, -112.37016573607143, 8.871489794491447 },
        { -1.0463969933192165, 15.676258243172242, -109.56826939260459, 473.9203781402958, -1418.4930626780351, 3111.5271889841865, -5165.876116454051, 6606.913650795505, -6557.264558406749, 5041.792678064538, -2967.7130573373242, 1300.8461693866682, -398.57522274037103, 75.44070268765269, -6.580342299559207 },
        { 0.346394204086217, -5.209814117503301, 36.58107355605999, -159.0865578865305, 479.2768376068324, -1059.7361823363078, 1777.0756410260287, -2302.221245421917, 2324.5175213683133, -1830.8673504280216, 1117.342094017506, -519.9638435640238, 178.65310800316172, -39.89326400096608, 4.185587973281072 },
        { -0.07142857142850927, 1.0769230769224205, -7.58333333333051, 33.090909090903544, -100.0999999999998, 222.44444444447325, -375.37500000008623, 490.28571428586224, -500.5000000001739, 400.4000000001471, -250.25000000009027, 121.33333333337285, -45.50000000001179, 14.000000000002148, -2.2515623265625013 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_15d[16][16] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.318228993228746, 14.999999999996184, -52.499999999970086, 151.6666666665475, -341.24999999965, 600.5999999992699, -834.1666666655251, 919.2857142842847, -804.3749999989207, 556.1111111103771, -300.2999999997057, 124.09090909084104, -37.91666666666399, 8.076923076929804, -1.071428571430545, 0.066666666666926 },
        { 4.4673313364628155, -44.51450335377097, 212.05076173812273, -666.7577561321965, 1561.1424512970605, -2811.9607142822993, 3965.084325391491, -4416.587099118735, 3895.293367341893, -2709.5932539648657, 1470.3303571415242, -609.99188311659, 187.00193903318996, -39.945679320716806, 5.311531580674413, -0.331175570462574 },
        { -7.3283520255547545, 88.14150086564388, -493.77541757653637, 1729.880253673297, -4286.310124023079, 7989.753826520909, -11526.890044464226, 13050.872322811665, -11652.1760676999, 8182.752322073293, -4474.137421503496, 1867.733739474101, -575.5486645052055, 123.48205023012291, -16.480846469105813, 1.0309226161110867 },
        { 10.379606975086277, -138.29939787683415, 853.845668624857, -3250.826614478377, 8574.88302990668, -16680.538581710476, 24801.889884327848, -28712.485746836315, 26075.164449679007, -18558.500532806545, 10257.830996117687, -4320.517356526336, 1341.3710161370018, -289.62026512328373, 38.866627602024074, -2.4427840085288586 },
        { -12.799791165298737, 181.46363596290905, -1192.7016576438177, 4822.86336836305, -13431.67494157019, 27340.364579583507, -42123.63520418556, 50142.31670746671, -46554.85296148447, 33732.22174028468, -18920.920055103066, 8067.78443755855, -2530.935778660392, 551.3510648793173, -74.5631474610174, 4.718003170515169 },
        { 13.801772476137398, -203.67726522673158, 1396.3648607916298, -5896.842856557581, 17149.09496282294, -36379.553669389104, 58183.160489694645, -71516.68359176166, 68221.1903625119, -50570.066086223946, 28917.71956594421, -12534.795619611075, 3988.2883683661717, -879.5524133370902, 120.23099420317843, -7.679874699215353 },
        { -13.025411908249737, 197.4910730773243, -1394.1855120759187, 6075.736299873925, -18268.29800013843, 40118.60292124955, -66437.72906800687, 84453.62439171186, -83092.69847299391, 63323.87290007349, -37108.730038999594, 16436.007705013017, -5329.866891788275, 1195.3060492575014, -165.84265627439333, 10.734711925936029 },
        { 10.734711925879566, -165.8426562737235, 1195.306049253732, -5329.866891776202, 16436.00770498659, -37108.73003896111, 63323.87290004085, -83092.69847298665, 84453.62439174438, -66437.72906805918, 40118.60292129985, -18268.29800017068, 6075.736299888115, -1394.1855120801754, 197.49107307807566, -13.02541190831152 },
        { -7.679874699172232, 120.23099420268272, -879.5524133343217, 3988.2883683577456, -12534.795619593537, 28917.71956592133, -50570.06608621249, 68221.19036252587, -71516.68359180992, 58183.16048975458, -36379.55366944107, 17149.094962854757, -5896.842856571188, 1396.3648607956056, -203.6772652274269, 13.80177247619358 },
        { 4.718003170487651, -74.56314746071205, 551.3510648776316, -2530.935778655546, 8067.784437549099, -18920.92005509289, 33732.22174028664, -46554.85296150654, 50142.31670751403, -42123.63520423765, 27340.36457962608, -13431.674941595447, 4822.8633683736225, -1192.7016576468645, 181.4636359634349, -12.799791165340741 },
        { -2.442784008514318, 38.866627601868274, -289.62026512243926, 1341.3710161347037, -4320.517356522197, 10257.830996114615, -18558.5005328124, 26075.16444969738, -28712.48574687015, 24801.889884362703, -16680.538581737925, 8574.883029922614, -3250.8266144849485, 853.8456686267403, -138.29939787715426, 10.37960697511165 },
        { 1.030922616104889, -16.480846469041442, 123.48205022978233, -575.5486645043203, 1867.7337394726453, -4474.137421503071, 8182.752322077626, -11652.176067710247, 13050.87232282953, -11526.890044481926, 7989.753826534523, -4286.310124030865, 1729.8802536764767, -493.77541757744643, 88.14150086579633, -7.3283520255667725 },
        { -0.33117557046057405, 5.311531580654173, -39.945679320612506, 187.00193903292774, -609.9918831161987, 1470.3303571416172, -2709.593253966741, 3895.2933673458783, -4416.587099125415, 3965.0843253979474, -2811.960714287199, 1561.1424512998349, -666.7577561333219, 212.0507617384452, -44.514503353824296, 4.467331336467004 },
        { 0.06666666666652261, -1.0714285714265388, 8.076923076909624, -37.91666666661434, 124.09090909077311, -300.2999999997569, 556.1111111108225, -804.3749999998153, 919.2857142857634, -834.1666666669329, 600.6000000003307, -341.250000000247, 151.66666666678861, -52.5000000000393, 15.00000000000752, -2.3182289932296345 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_16d[17][17] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.3807289932296594, 16.000000000010534, -60.00000000007723, 186.6666666670418, -455.0000000012259, 873.6000000029827, -1334.666666672231, 1634.285714293746, -1608.7500000094317, 1271.1111111192865, -800.8000000057949, 397.090909094252, -151.6666666680644, 43.076923077353406, -8.571428571521846, 1.0666666666785913, -0.06250000000062526 },
        { 4.739856138573637, -49.26221630226725, 248.73331113368636, -840.207338342488, 2128.894276100223, -4180.661010115464, 6482.030617311003, -8020.191685602187, 7956.161904807624, -6324.012698452616, 4003.109925954322, -1992.7143434506513, 763.5573512975188, -217.45744625954802, 43.37006485623377, -5.407999605391258, 0.31743053243358604 },
        { -8.079287029860504, 101.67212720174803, -601.9561532356445, 2253.315400231295, -6025.600684412748, 12225.934058670282, -19374.570755435132, 24349.026809317234, -24438.800379145432, 19602.74235047863, -12499.063452240314, 6259.003131774588, -2410.185381270812, 689.2869010418206, -137.9660763739758, 17.2570738840149, -1.0156834582743195 },
        { 11.96024933179675, -167.1432528058437, 1089.9761464687606, -4420.237085604744, 12535.510007464436, -26471.380756855342, 43150.62466721845, -55371.05304031373, 56468.32239087731, -45867.12825638976, 29544.261780128993, -14918.886609442654, 5785.335815027931, -1664.4390789341214, 334.86371307053514, -42.07262370825691, 2.485934470744356 },
        { -15.512748243716445, 231.114598688907, -1605.0026388548922, 6902.882208355697, -20610.035463843262, 45391.05974807333, -76453.92914695259, 100646.70001998816, -104745.20642110839, 86487.69166232098, -56465.718987947985, 28836.495161280942, -11289.622127911267, 3274.696050537497, -663.5104550911648, 83.88197792369343, -4.983437221611652 },
        { 17.717746309085705, -275.20612912297366, 1994.8471865408285, -8955.773737308704, 27874.20044883406, -63802.17731233461, 111188.91959138872, -150672.71207973832, 160665.23638541682, -135396.3392062218, 89935.80507548369, -46610.20529528958, 18480.579106703466, -5419.725990746016, 1108.7320409575682, -141.35932990869892, 8.461499042065611 },
        { -17.857137245788763, 285.3557827974174, -2131.57430565991, 9876.054613715016, -31753.814248626775, 75100.74650611158, -135129.1903709855, 188700.18757029678, -206772.68752796468, 178521.92633170908, -121136.7198050673, 63967.70720943067, -25784.40993890545, 7672.636943878782, -1590.0304415829742, 205.07124051094806, -12.402422416398025 },
        { 15.873010885156893, -258.74701596530787, 1974.9614367479962, -9366.293257490943, 30878.68124758326, -75002.91489197082, 138771.46330676248, -199399.2016939826, 224773.35571488304, -199399.20169404487, 138771.46330685102, -75002.91489204257, 30878.681247620778, -9366.293257504167, 1974.961436751038, -258.7470159656976, 15.873010885169975 },
        { -12.402422416386448, 205.07124051058804, -1590.030441580222, 7672.636943866908, -25784.409938871817, 63967.70720936756, -121136.71980499246, 178521.92633166368, -206772.68752797673, 188700.18757036552, -135129.1903710736, 75100.74650618128, -31753.814248662573, 9876.054613727532, -2131.57430566278, 285.3557827977777, -17.85713724580111 },
        { 8.461499042056994, -141.35932990841533, 1108.7320409554359, -5419.725990736937, 18480.57910667769, -46610.205295241954, 89935.80507543053, -135396.33920619538, 160665.236385434, -150672.71207979994, 111188.91959146214, -63802.17731239191, 27874.200448863055, -8955.773737318726, 1994.8471865431284, -275.20612912325635, 17.717746309095446 },
        { -4.9834372216062075, 83.88197792350499, -663.5104550897566, 3274.6960505316138, -11289.622127894556, 28836.495161250303, -56465.718987916516, 86487.69166230886, -104745.20642112268, 100646.70002003293, -76453.92914700335, 45391.05974811261, -20610.035463862932, 6902.882208362435, -1605.0026388564465, 231.11459868909353, -15.512748243722902 },
        { 2.4859344707414435, -42.072623708153344, 334.8637130697566, -1664.4390789309398, 5785.335815018944, -14918.886609426165, 29544.261780113746, -45867.12825638548, 56468.32239088536, -55371.05304033992, 43150.62466724713, -26471.380756877374, 12535.51000747541, -4420.237085608486, 1089.976146469633, -167.14325280594568, 11.960249331800322 },
        { -1.01568345827304, 17.257073883969316, -137.9660763736283, 689.2869010404302, -2410.185381266929, 6259.003131767409, -12499.06345223441, 19602.742350477496, -24438.800379148593, 24349.026809329207, -19374.570755447985, 12225.934058680074, -6025.600684417625, 2253.315400232955, -601.9561532360372, 101.67212720179282, -8.079287029862101 },
        { 0.3174305324331589, -5.407999605376218, 43.370064856117395, -217.4574462590897, 763.5573512962543, -1992.714343448288, 4003.109925952586, -6324.012698452405, 7956.161904808461, -8020.191685606206, 6482.0306173152885, -4180.661010118691, 2128.894276101842, -840.2073383430377, 248.73331113381852, -49.26221630228207, 4.739856138574172 },
        { -0.06250000000053688, 1.0666666666755211, -8.571428571497819, 43.07692307725973, -151.66666666780822, 397.0909090937687, -800.8000000054702, 1271.1111111192627, -1608.7500000095629, 1634.2857142945702, -1334.66666667311, 873.6000000036372, -455.00000000155734, 186.66666666715395, -60.00000000010458, 16.000000000013575, -2.3807289932297695 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_17d[18][18] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.439552522639725, 16.999999999982524, -67.99999999984983, 226.66666666587324, -594.9999999971743, 1237.5999999924616, -2062.666666651146, 2778.2857142614225, -3038.749999968576, 2701.1111110802735, -1944.7999999739304, 1125.090909075112, -515.6666666588073, 183.0769230738342, -48.57142857058552, 9.066666666492756, -1.0624999999773899, 0.058823529410400595 },
        { 5.003779445594579, -54.12883488031099, 288.7653395208474, -1042.828909512493, 2842.790470799938, -6044.499179255643, 10220.270854300283, -13906.647137067737, 15325.705015965954, -13702.569196275945, 9911.768710189197, -5755.8157827503155, 2646.3836857775013, -942.0383401168187, 250.49565067448899, -46.8509341575702, 5.499751398662544, -0.3049440653232888 },
        { -8.831510437690751, 116.00618033812225, -723.7257985379805, 2882.939043848173, -8274.83201237627, 18153.7436961972, -31344.40619044635, 43293.23068004392, -48249.51465797346, 43517.58617534423, -31698.943283893284, 18513.095825609722, -8552.42773538376, 3056.688661621496, -815.6029062598379, 153.00048279613313, -18.007406354398316, 1.0007558890988426 },
        { 13.60648043681022, -198.91646602306042, 1366.080736262301, -5879.153718624007, 17839.2925819118, -40639.69415112, 72061.46075719075, -101506.3815529637, 114841.167379801, -104814.5279095381, 77084.17291004639, -45376.63815672129, 21101.843650376413, -7584.530937539445, 2033.5806518284285, -383.09430792487876, 45.25534125174238, -2.5232886964383425 },
        { -18.466308384913425, 288.3113037948127, -2109.0330242159516, 9613.17458825835, -30635.32643334034, 72590.07586242183, -132693.4976742414, 191398.69893083657, -220652.86844546522, 204471.53618819802, -152266.57406497875, 90574.64346491134, -42494.81082580801, 15389.943038980176, -4153.576150888147, 786.9742090687173, -93.43792079168608, 5.2332617063871 },
        { 22.200240733092325, -361.8911312599003, 2764.652405656255, -13147.680115592057, 43610.94920227418, -107150.08665038385, 202127.9232738702, -299376.4302607216, 352855.96563651605, -333099.9431491185, 251969.54972463794, -151896.1678592352, 72087.82177982948, -26368.733272759073, 7178.921302682954, -1370.6718855794952, 163.85391257477335, -9.23315419234663 },
        { -23.71046863263945, 398.1163910831119, -3136.3724286396773, 15393.055417905194, -52703.540977413024, 133582.33437152524, -259566.98857618973, 395090.0443253918, -477192.3702159815, 460295.53129027324, -354834.3235885546, 217484.5643634084, -104731.52959642647, 38805.78775352384, -10686.273589316119, 2061.207815902274, -248.65971371981487, 14.127425920935165 },
        { 22.511114041729186, -385.9705420001493, 3109.206819608061, -15624.064411277162, 54835.90563373609, -142601.35133056642, 284434.1389612274, -444361.12619152514, 550409.4039841441, -543685.4330188389, 428417.6025844665, -267897.1294809329, 131372.5873525909, -49483.22522210634, 13830.525521391968, -2703.7966851538818, 330.18328605405316, -18.968374906003817 },
        { -18.968374906096646, 330.18328605521873, -2703.7966851608526, 13830.525521418367, -49483.22522217935, 131372.58735275085, -267897.12948118115, 428417.6025848301, -543685.4330192207, 550409.4039845243, -444361.1261917764, 284434.13896136126, -142601.35133059797, 54835.90563373502, -15624.064411270901, 3109.206819605002, -385.9705419994573, 22.511114041662957 },
        { 14.127425921037187, -248.65971372121695, 2061.20781591154, -10686.273589355607, 38805.78775364749, -104731.52959672471, 217484.56436393913, -354834.3235893849, 460295.5312912379, -477192.3702169439, 395090.04432611814, -259566.98857662565, 133582.33437171107, -52703.54097747146, 15393.055417916625, -3136.372428640304, 398.11639108290774, -23.710468632604528 },
        { -9.233154192436613, 163.8539125760783, -1370.6718855885263, 7178.921302723289, -26368.733272891797, 72087.82178015764, -151896.16785983997, 251969.5497256045, -333099.9431502584, 352855.9656376551, -299376.43026159913, 202127.92327440908, -107150.08665062721, 43610.94920235705, -13147.680115611869, 2764.6524056589187, -361.89113126001087, 22.20024073308143 },
        { 5.2332617064512785, -93.43792079265026, 786.9742090755561, -4153.576150919372, 15389.943039086107, -42494.81082607173, 90574.64346540673, -152266.57406578158, 204471.5361891442, -220652.86844641404, 191398.69893157022, -132693.49767469752, 72590.07586263197, -30635.326433413946, 9613.174588277016, -2109.033024218827, 288.31130379502287, -18.466308384914846 },
        { -2.523288696475173, 45.255341252309286, -383.0943079289584, 2033.5806518472475, -7584.530937604786, 21101.84365053901, -45376.63815703165, 77084.17291055493, -104814.52791013318, 114841.16738040088, -101506.38155342608, 72061.46075748079, -40639.69415125509, 17839.29258195987, -5879.153718636545, 1366.0807362643382, -198.91646602323152, 13.606480436814731 },
        { 1.0007558891154638, -18.007406354658556, 153.00048279802294, -815.6029062685919, 3056.6886616524603, -8552.42773546056, 18513.095825758483, -31698.943284139117, 43517.586175629316, -48249.51465826257, 43293.23068026542, -31344.406190586265, 18153.74369626289, -8274.832012399895, 2882.9390438544337, -723.725798539026, 116.00618033821542, -8.831510437694021 },
        { -0.3049440653288415, 5.4997513987505435, -46.850934158212795, 250.49565067746946, -942.0383401275128, 2646.383685803932, -5755.815782802156, 9911.768710275332, -13702.569196375076, 15325.705016067031, -13906.647137144691, 10220.270854349146, -6044.499179278724, 2842.790470808297, -1042.8289095147313, 288.76533952122674, -54.12883488034598, 5.003779445595979 },
        { 0.05882352941153826, -1.062499999995565, 9.066666666625899, -48.57142857120318, 183.07692307607206, -515.666666664324, 1125.09090908603, -1944.799999992125, 2701.111111101108, -3038.7499999899023, 2778.285714277579, -2062.666666661441, 1237.5999999973449, -594.9999999989502, 226.66666666635194, -67.99999999993162, 16.999999999990226, -2.4395525226400556 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_18d[19][19] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.4951080781954453, 17.999999999982652, -76.49999999984537, 271.9999999991552, -764.9999999964399, 1713.599999988915, -3093.999999974011, 4546.285714236073, -5469.749999925617, 5402.222222133506, -4375.799999910219, 2893.0909090204564, -1546.9999999542345, 659.0769230536488, -218.57142856279518, 54.399999997446045, -9.562499999497934, 1.0588235293490902, -0.055555555551741055 },
        { 5.259664532681182, -59.107649098222225, 332.20750866704617, -1277.18225303689, 3727.07508666044, -8530.088194104137, 15619.948128213338, -23180.98500466495, 28096.46186937796, -27908.480858565017, 22708.82949534958, -15069.798013396812, 8082.974063941478, -3452.5806662757764, 1147.5316573747255, -286.1564505953914, 50.38531358093922, -5.587240095227624, 0.293542126827321 },
        { -9.583719779152606, 131.1189888595361, -859.6683735287378, 3631.0136787664096, -11133.903339641165, 26260.325863514474, -49065.25141791104, 73872.6781742434, -90510.4357602287, 90663.99342973605, -74270.11078391068, 49558.21989930859, -26703.587163985314, 11450.53268555387, -3818.4669083097706, 954.943541263205, -168.5665487714993, 18.733941930926207, -0.9861870998176488 },
        { 15.312124463639972, -233.62730608828795, 1685.1827060382238, -7671.152971943365, 24799.775911924673, -60621.61935931045, 116161.6050936697, -178181.40604069977, 221448.5008016088, -224335.17810206467, 185450.6265423128, -124677.66858493455, 67604.39130186143, -29144.347400017352, 9763.760338775406, -2451.570586438501, 434.27385288542916, -48.41398064888032, 2.5556586076325334 },
        { -21.651860305565318, 353.380043826909, -2715.476335035261, 13075.855897895457, -44303.12077568803, 112386.85939994326, -221585.58051313684, 347514.2558287017, -439554.3728977428, 451648.5016873917, -377746.3553044953, 256445.81819828635, -140206.86505521656, 60872.94907202104, -20518.79525709901, 5179.756484648002, -921.8982827122028, 103.20828456638367, -5.468615879603228 },
        { 27.25818913674773, -465.11168951166144, 3734.2158278988077, -18751.490107558137, 66039.32016549908, -173372.98445111854, 351998.8814331709, -565728.8985732498, 730293.1228499023, -763282.3358787127, 647630.1699629115, -445080.7432857854, 245914.27824462933, -107746.92633134326, 36610.19619469963, -9307.177067849118, 1666.8873090621423, -187.6559580320027, 9.993166294453937 },
        { -30.65866889485505, 539.4401591856227, -4468.79989387676, 23157.54202738299, -84121.12556918371, 227502.11908056695, -474871.4288096277, 782612.0929322719, -1032997.1382332874, 1100927.3191901732, -950174.6195947868, 662815.0346560463, -371043.39741433883, 164461.06607585333, -56455.84470171884, 14484.040309948281, -2615.3486866499925, 296.6077512451019, -15.90061032920713 },
        { 30.852798528797944, -554.8552841988833, 4702.973030666402, -24957.914743338395, 92906.13177393301, -257567.27324794937, 551054.3494302302, -930237.2569388264, 1256195.0200486144, -1367506.6502705596, 1203397.7924383483, -854384.2233111926, 485963.3420562125, -218517.32705934413, 75992.52487747201, -19726.6621958119, 3600.1489436907727, -412.2695602325099, 22.29721374107379 },
        { -27.76751867591258, 507.390202751451, -4374.467395914812, 23639.15509211507, -89704.41707884384, 253776.1406527107, -554530.8211197574, 956682.0592001316, -1320645.5374271753, 1469357.5307842519, -1320645.5374235436, 956682.0591949864, -554530.8211153474, 253776.1406500565, -89704.41707770212, 23639.15509176078, -4374.467395839083, 507.3902027415347, -27.76751867529691 },
        { 22.297213741699636, -412.2695602425992, 3600.148943768451, -19726.662196178357, 75992.52487866701, -218517.32706218373, 485963.34206110047, -854384.223317292, 1203397.7924435055, -1367506.650272542, 1256195.0200470146, -930237.2569353412, 551054.3494269042, -257567.2732458445, 92906.13177300282, -24957.91474304501, 4702.973030603052, -554.8552841905066, 30.852798528276715 },
        { -15.900610329754507, 296.6077512539319, -2615.348686718452, 14484.040310273676, -56455.84470278899, 164461.06607844552, -371043.39741892234, 662815.0346620411, -950174.6196003929, 1100927.3191934046, -1032997.1382334615, 782612.0929305373, -474871.4288075873, 227502.11907916996, -84121.12556854312, 23157.542027176318, -4468.799893831542, 539.4401591795714, -30.658668894476722 },
        { 9.993166294863727, -187.65595803861984, 1666.887309113765, -9307.17706809638, 36610.196195517376, -107746.92633335921, 245914.27824826833, -445080.7432907096, 647630.1699678267, -763282.3358821116, 730293.1228510592, -565728.8985728108, 351998.8814322061, -173372.9844503598, 66039.320165131, -18751.490107435424, 3734.2158278714987, -465.1116895079528, 27.25818913651391 },
        { -5.468615879862974, 103.20828457058452, -921.898282745156, 5179.756484807253, -20518.79525762717, 60872.9490733446, -140206.86505764214, 256445.8182016474, -377746.35530801216, 451648.50169007486, -439554.3728990393, 347514.2558288946, -221585.5805128284, 112386.8593996177, -44303.12077551437, 13075.855897834661, -2715.4763350214525, 353.38004382500134, -21.651860305443428 },
        { 2.555658607769381, -48.41398065109797, 434.27385290290846, -2451.570586523853, 9763.760339058586, -29144.347400737726, 67604.39130319504, -124677.66858681077, 185450.62654434986, -224335.17810370456, 221448.50080254293, -178181.4060410099, 116161.6050936386, -60621.619359207056, 24799.775911858906, -7671.152971918551, 1685.1827060324651, -233.62730608747722, 15.31212446358714 },
        { -0.9861870998756681, 18.73394193186841, -168.56654877895494, 954.9435413000087, -3818.4669084317225, 11450.532685868166, -26703.58716457076, 49558.21990013957, -74270.11078483968, 90663.9934305051, -90510.43576071125, 73872.67817444596, -49065.25141794181, 26260.32586349376, -11133.903339621851, 3631.0136787582474, -859.6683735268056, 131.11898885925856, -9.583719779134029 },
        { 0.29354212684584274, -5.5872400955289985, 50.38531358333099, -286.15645060731407, 1147.5316574141564, -3452.5806663784488, 8082.974064133399, -15069.798013670561, 22708.82949566234, -27908.48085882753, 28096.461869553026, -23180.985004746817, 15619.948128233615, -8530.088194103073, 3727.0750866562958, -1277.1822530348318, 332.2075086665511, -59.10764909814956, 5.259664532676159 },
        { -0.0555555555554168, 1.0588235294089898, -9.562499999974243, 54.39999999983784, -218.5714285706918, 659.0769230743579, -1546.9999999930183, 2893.0909090759214, -4375.799999974509, 5402.222222187824, -5469.749999963214, 4546.285714254654, -3093.999999979436, 1713.5999999894514, -764.9999999958864, 271.99999999881885, -76.49999999976352, 17.99999999997038, -2.49510807819457 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_19d[20][20] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.5477396571410074, 18.999999999950674, -85.49999999953427, 322.999999997257, -968.9999999883966, 2325.59999996597, -4521.999999915252, 7198.285714126446, -9447.749999752572, 10264.222221919308, -9237.799999695166, 6871.090908839823, -4198.999999834958, 2087.0769229935545, -830.5714285378289, 258.39999998944546, -60.562499997699085, 10.05882352903164, -1.055555555519905, 0.05263157894568226 },
        { 5.508024862819185, -64.19266846960267, 379.1170081118964, -1545.8679565656012, 4808.076091901284, -11784.86262052853, 23233.22546574601, -37345.32035577143, 49371.898145324754, -53939.5625253272, 48762.29540842844, -36401.345344989735, 22312.422323562016, -11118.441996450283, 4434.320323545697, -1382.1639948381444, 324.47741198552103, -53.9705130633727, 5.67085469532798, -0.28308218411816416 },
        { -10.334874278289403, 146.98746053291532, -1010.3456154089625, 4510.256379027848, -14713.757718275634, 37126.266080739966, -74629.38087871755, 121640.79667021683, -162501.8887203392, 178984.12684802077, -162859.86063170468, 122224.04928484836, -75250.61503692842, 37638.73613890262, -15059.588411716304, 4707.109729447749, -1107.7369137123821, 184.64669639357004, -19.438491379655705, 0.9720043875291371 },
        { 17.071671793132023, -271.2788312152287, 2050.2663835045723, -9842.605689301761, 33774.69472298656, -88176.83594446791, 181563.68408073005, -301236.7749039352, 407936.19093933544, -454159.5565710119, 416846.1639825287, -315083.78389962355, 195157.60316592088, -98113.03754688479, 39428.687534187404, -12371.217373446607, 2921.1274936017708, -488.36342847634677, 51.54793226374229, -2.5837185695091676 },
        { -25.060768828796203, 426.6181851441779, -3435.222189340252, 17424.984261354417, -62550.481389642955, 169146.8592886308, -357791.9716413598, 606147.5842275565, -834525.5312933078, 941566.4990658351, -873742.5188191594, 666522.4418183747, -416051.0373690052, 210561.6706971062, -85107.97987657094, 26838.696177837148, -6365.482643627621, 1068.4144077957828, -113.17269601729757, 5.690557264265625 },
        { 32.89737564094115, -586.204377678026, 4933.641579777946, -26084.866674611134, 97212.64701070356, -271600.2641811515, 590552.2275626241, -1023594.3284101941, 1436193.0384556442, -1646216.4458514813, 1548108.329318018, -1194410.5724931294, 752861.4683205922, -384252.4217435669, 156464.87385809983, -49663.442139231214, 11847.250900886658, -1998.7968682615196, 212.7086869299177, -10.740329497912965 },
        { -38.76795507118574, 713.0705120841188, -6195.448700224208, 33800.25674099713, -129837.16126275249, 373227.0011616997, -832971.4044080867, 1477838.0285210335, -2116451.079915035, 2469666.8358047735, -2358887.278855696, 1844830.6588211707, -1176762.6425187942, 606943.3167925134, -249452.2548340719, 79837.35354737891, -19187.128901453445, 3258.8319368270786, -348.9004591269289, 17.713971498875683 },
        { 41.098175147384204, -773.3083754462078, 6878.1527073978505, -38433.9362126991, 151244.9773845003, -445320.5111292181, 1017395.8583750661, -1845837.9371250574, 2699339.178664583, -3210973.967328733, 3120988.7604833026, -2479659.8031746238, 1604334.2324639673, -838129.7990702598, 348467.6464542387, -112696.79418012098, 27341.476421179348, -4683.898907943964, 505.41967857890944, -25.84530338090632 },
        { -39.20971214858785, 750.1831119566402, -6790.653420541131, 38649.68815480868, -155037.13972777216, 465613.3433172328, -1085494.3520355334, 2009943.9223869334, -2999314.6609317428, 3638639.7798097036, -3603753.6878341674, 2914369.942327, -1916993.3529439375, 1016915.6189851316, -428818.66360120365, 140500.73639147534, -34498.33329783846, 5975.623310985414, -651.4100704478398, 33.62577966656613 },
        { 33.62577966549434, -651.4100704283738, 5975.62331084347, -34498.33329719118, 140500.73638942235, -428818.6635964052, 1016915.6189767567, -1916993.3529329402, 2914369.9423173987, -3603753.6878298735, 3638639.7798130424, -2999314.6609406117, 2009943.9223975777, -1085494.3520437402, 465613.3433219917, -155037.13972982994, 38649.68815545955, -6790.65342068447, 750.1831119763534, -39.209712149668576 },
        { -25.845303379976365, 505.4196785621199, -4683.898907821155, 27341.476420616695, -112696.79417833503, 348467.6464500263, -838129.7990628432, 1604334.2324541793, -2479659.8031657953, 3120988.760478971, -3210973.9673310816, 2699339.1786719123, -1845837.9371341947, 1017395.8583821779, -445320.5111333791, 151244.97738631652, -38433.936213274785, 6878.152707524963, -773.3083754637111, 41.0981751483415 },
        { 17.713971498173883, -348.9004591143509, 3258.8319367348995, -19187.12890102911, 79837.35354603842, -249452.2548308947, 606943.3167869082, -1176762.64251148, 1844830.6588145266, -2358887.27885249, 2469666.835806645, -2116451.079920732, 1477838.028528147, -832971.4044136172, 373227.0011649309, -129837.16126417162, 33800.25674144629, -6195.44870032334, 713.0705120977524, -38.76795507193113 },
        { -10.740329497455617, 212.70868692179297, -1998.7968682020014, 11847.250900611238, -49663.442138371385, 156464.87385606355, -384252.42173999886, 752861.4683160962, -1194410.5724891527, 1548108.329316409, -1646216.4458531989, 1436193.0384598502, -1023594.3284152215, 590552.2275664868, -271600.2641833739, 97212.64701168309, -26084.866674919125, 4933.641579845637, -586.2043776872972, 32.89737564144886 },
        { 5.690557264010703, -113.17269601281814, 1068.4144077630735, -6365.4826434752595, 26838.696177370173, -85107.97987547221, 210561.67069521453, -416051.0373667716, 666522.441816544, -873742.5188187525, 941566.4990672958, -834525.5312961382, 606147.5842307038, -357791.9716437392, 169146.8592899645, -62550.48139023275, 17424.984261537695, -3435.222189380235, 426.6181851496158, -25.060768829095007 },
        { -2.583718569389501, 51.54793226166743, -488.3634284612827, 2921.1274935309953, -12371.217373234602, 39428.687533694036, -98113.03754606048, 195157.60316504166, -315083.7838990134, 416846.16398263443, -454159.5565720058, 407936.1909409655, -301236.77490561106, 181563.68408198052, -88176.83594514789, 33774.694723288776, -9842.605689394253, 2050.266383524562, -271.27883121792195, 17.071671793280725 },
        { 0.972004387483186, -19.4384913788709, 184.646696387914, -1107.7369136855318, 4707.109729369266, -15059.588411536122, 37638.736138613756, -75250.61503666207, 122224.04928472175, -162859.86063186632, 178984.1268485298, -162501.8887210924, 121640.79667093899, -74629.38087925258, 37126.26608102269, -14713.757718402121, 4510.256379065945, -1010.3456154171174, 146.9874605340025, -10.334874278349758 },
        { -0.2830821841046222, 5.6708546951001555, -53.97051306174318, 324.47741197770324, -1382.163994815804, 4434.320323495097, -11118.441996372907, 22312.422323503226, -36401.34534498274, 48762.29540850861, -53939.56252551178, 49371.89814558207, -37345.320356005024, 23233.22546591868, -11784.862620617621, 4808.076091941434, -1545.86795657752, 379.1170081144262, -64.19266846993659, 5.508024862837816 },
        { 0.05263157894314815, -1.0555555554778033, 10.058823528732416, -60.56249999625075, 258.3999999853799, -830.571428528722, 2087.0769229802254, -4198.9999998268695, 6871.090908843044, -9237.79999971488, 10264.222221958888, -9447.749999805963, 7198.285714173143, -4521.999999949769, 2325.599999983475, -968.9999999963354, 322.9999999995879, -85.50000000002585, 19.000000000015064, -2.547739657144614 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_20d[21][21] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.5977396572397167, 20.000000001917122, -95.00000001815674, 380.0000001087292, -1211.2500004608683, 3100.8000014673144, -6460.0000036594365, 11074.285721571445, -15746.250011736629, 18662.22223783763, -18475.600017057586, 15269.090924475327, -10497.500011461509, 5963.076930105131, -2768.571432057219, 1033.6000013840026, -302.8125004310447, 67.05882363035158, -10.555555572272043, 1.0526315807004871, -0.0500000000874192 },
        { 5.749328472193763, -69.37851188994077, 429.5479315254365, -1851.5250596271815, 6114.236128169994, -15978.84448964718, 33742.59268997055, -58399.54665758588, 83628.81969682554, -99661.31718059999, 99096.88179509497, -82190.48082926418, 56673.37981725906, -32273.635875267715, 15016.213203880528, -5616.414834652337, 1648.090283725104, -365.4940420998378, 57.60409123549658, -5.750932038585304, 0.2734462801652042 },
        { -11.084139843584483, 163.589943860744, -1176.2987858824183, 5533.820176981431, -19136.75629554411, 51435.63686873522, -110680.0871173814, 194156.30385581614, -280860.6734596902, 337349.4394285029, -337558.1637269488, 281415.6044483275, -194881.54344907706, 111382.60796759157, -51985.50187379369, 19496.33000669507, -5734.558005456597, 1274.3941883792934, -201.2244448387225, 20.12263561612007, -0.9582214135195013 },
        { 18.88019609057374, -311.8698833933752, 2464.276854849817, -12442.623175155612, 45168.53237902045, -125432.26028120224, 276192.3133731581, -492800.6209227325, 722207.4663864194, -876418.268074855, 884274.0049860032, -742269.5647624966, 516986.85487853567, -296926.1931937259, 139168.27233929132, -52384.13233507763, 15457.572353648338, -3444.9163484268474, 545.3239551577642, -54.65675922910368, 2.6080329080381097 },
        { -28.684497934436454, 508.29707883306054, -4279.33777602546, 22806.653851480714, -86468.31903143076, 248305.4563435251, -560897.6889592359, 1020778.9268017362, -1519542.0491745477, 1867422.0068004725, -1903807.8179219484, 1611986.6099261222, -1131012.2715618212, 653686.8435242671, -308056.214024502, 116509.3864081329, -34524.623312243304, 7723.046365331506, -1226.6336339186569, 123.3128566748928, -5.900061285552777 },
        { 39.120968433918584, -726.4618706381431, 6394.602438942518, -35505.791672034684, 139603.47459664618, -413592.5821465775, 958910.3440495067, -1782989.689502061, 2701660.976875785, -3369569.9303871947, 3478183.3554187845, -2976330.401045597, 2107320.865654006, -1227588.8530284776, 582511.0151709669, -221651.79185158596, 66035.73397270113, -14843.233279631906, 2367.72944409322, -238.95760691143377, 11.473799185531654 },
        { -48.097908319107596, 922.8059160683008, -8389.209040274098, 48059.93699776561, -194645.7810456208, 592674.1162431409, -1408485.8267637654, 2676734.5367637533, -4133839.7614703123, 5241660.443282722, -5488741.969305215, 4755826.5279105045, -3404283.3748376234, 2002308.750813359, -958268.1662964678, 367412.364670789, -110208.71586898263, 24924.364148974488, -3997.8950352272755, 405.5113099618719, -19.56048423257738 },
        { 53.44235563048125, -1049.7544141211304, 9774.242738183184, -57356.59093654208, 237900.74153323728, -741426.1747963966, 1801712.5088280097, -3496566.8655586382, 5505522.546952455, -7105109.661018415, 7559392.205970919, -6644366.709136188, 4817620.680114402, -2866501.104373698, 1386192.9470769616, -536497.9525966985, 162302.01748993536, -36990.378923092125, 5975.256808001463, -609.9968268132062, 29.598712828207773 },
        { -53.720586416052065, 1073.7062882020502, -10179.218293392687, 60855.915629415635, -257278.57432883035, 817501.9520055591, -2025567.370670364, 4007320.59931249, -6429037.521534403, 8447279.565743579, -9141149.633187996, 8163017.773829227, -6006356.584983998, 3622587.718589072, -1773822.6648862865, 694445.7937359796, -212313.57149512263, 48860.93699650851, -7963.768243143374, 819.7478459821433, -40.08176673502356 },
        { 48.83689674754607, -988.9228096989877, 9505.590500716089, -57660.24381822217, 247515.37148446726, -799118.2102002596, 2013069.0001796293, -4051068.7519803774, 6613090.359253244, -8842234.209112382, 9735683.35918855, -8842234.209033934, 6613090.359139999, -4051068.751877973, 2013069.0001140656, -799118.2101688288, 247515.37147312763, -57660.24381525997, 9505.590500177976, -988.9228096377947, 48.836896744259846 },
        { -40.08176673671595, 819.7478460117106, -7963.768243380313, 48860.93699766871, -212313.57149881183, 694445.7937429674, -1773822.6648908467, 3622587.718570686, -6006356.584903323, 8163017.773652312, -9141149.632911496, 8447279.565418757, -6429037.5212405985, 4007320.5991012543, -2025567.3705515084, 817501.9519533769, -257278.57431116857, 60855.91562499833, -10179.218292616637, 1073.7062881164, -53.72058641155621 },
        { 29.59871282849564, -609.996826815401, 5975.256807982965, -36990.37892275539, 162302.01748741773, -536497.9525844513, 1386192.9470350193, -2866501.104266526, 4817620.6798974145, -6644366.708788303, 7559392.205519312, -7105109.660546826, 5505522.546558156, -3496566.8652907135, 1801712.5086832964, -741426.1747348675, 237900.7415129314, -57356.590931558254, 9774.242737321054, -1049.7544140273271, 53.44235562561222 },
        { -19.560484232025665, 405.5113099482615, -3997.8950350672703, 24924.364147842713, -110208.71586333946, 367412.3646495709, -958268.1662346784, 2002308.7506723376, -3404283.374576906, 4755826.527519256, -5488741.968823626, 5241660.442800126, -4133839.7610797794, 2676734.5365046686, -1408485.8266265546, 592674.1161857509, -194645.78102692103, 48059.93699322264, -8389.209039494921, 922.8059159842073, -48.097908314770194 },
        { 11.473799184739553, -238.95760689398756, 2367.7294439068933, -14843.233278398746, 66035.73396690498, -221651.7918309986, 582511.0151136081, -1227588.8529022224, 2107320.8654287877, -2976330.400716848, 3478183.355023818, -3369569.9299993394, 2701660.976567562, -1782989.6893000333, 958910.3439437146, -413592.5821027629, 139603.47458247165, -35505.79166861268, 6394.602438358653, -726.4618705754388, 39.12096843069708 },
        { -5.900061284903886, 123.31285666105428, -1226.6336337755415, 7723.046364404976, -34524.62330798814, 116509.3863934044, -308056.21398426715, 653686.8434371114, -1131012.2714093735, 1611986.609706828, -1903807.81766192, 1867422.0065480485, -1519542.0489762886, 1020778.9266726165, -560897.6888920984, 248305.45631589936, -86468.31902253095, 22806.653849341103, -4279.337775661715, 508.2970787941062, -28.6844979324403 },
        { 2.6080329076511544, -54.65675922096676, 545.3239550750155, -3444.916347895909, 15457.572351239278, -52384.13232686516, 139168.27231709316, -296926.1931460025, 516986.8547961257, -742269.5646449851, 884274.0048477271, -876418.2679415595, 722207.4662825852, -492800.6208553385, 276192.3133382759, -125432.26026691328, 45168.532374428534, -12442.623174054857, 2464.276854663235, -311.869883373418, 18.880196089552875 },
        { -0.9582214133451015, 20.122635612477513, -201.22444480207164, 1274.3941881449246, -5734.55800440084, 19496.330003132214, -51985.5018642234, 111382.60794708546, -194881.54341398858, 281415.6043985749, -337558.1636686738, 337349.43937257165, -280860.6734163808, 194156.3038277549, -110680.0871029004, 51435.636862822226, -19136.756293646562, 5533.820176527491, -1176.2987858056767, 163.58994385253615, -11.084139843165149 },
        { 0.2734462801079724, -5.7509320373938255, 57.60409122359432, -365.49404202379054, 1648.0902833841003, -5616.414833509474, 15016.213200822367, -32273.635868723693, 56673.379806134275, -82190.48081354875, 99096.8817767388, -99661.31716302916, 83628.81968327826, -58399.54664881567, 33742.592685453266, -15978.844487806782, 6114.23612757982, -1851.525059486206, 429.54793150165824, -69.37851188739603, 5.749328472063871 },
        { -0.05000000007596005, 1.0526315804622906, -10.55555556990374, 67.05882361521815, -302.81250036337735, 1033.6000011582314, -2768.571431454465, 5963.0769288159, -10497.500009279342, 15269.090921399966, -18475.600013471343, 18662.222234410212, -15746.25000910165, 11074.285719866291, -6460.000002782175, 3100.800001110437, -1211.250000346466, 380.00000008142933, -95.00000001356013, 20.000000001424823, -2.597739657214603 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_21d[22][22] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.6453587048363665, 21.00000000169207, -105.00000001826551, 443.3333334576756, -1496.2500005928716, 4069.8000021326416, -9044.000005942466, 16611.428584738314, -25436.25002412458, 32658.888924922245, -35271.600044284256, 32065.090954528026, -24494.16670503491, 15653.076949896533, -8305.714301296954, 3617.600007315152, -1271.8125027696697, 352.0588243475518, -73.88888907091248, 11.052631607640782, -1.0500000028649201, 0.04761904775357185 },
        { 5.984002323099598, -74.66031888934516, 483.5515945005473, -2196.828954816369, 7676.141473454913, -21306.433810638377, 47980.710696898714, -88958.40741553565, 137171.42075052077, -177073.8812998283, 192062.79583321913, -175214.693430277, 134234.23742585434, -85993.5407936678, 45725.06089941587, -19951.980305769404, 7025.496436696859, -1947.4922016155583, 409.24001186976284, -61.28382449826909, 5.8277659596697085, -0.26453587121246885 },
        { -11.830846955921846, 180.9061021444317, -1358.0502595218463, 6715.27703915206, -24537.036600914947, 69986.3617600106, -160508.50755732929, 301506.7195543188, -469502.9376493765, 610728.9004020473, -666489.94626937, 611075.2213906809, -470109.5497065795, 302227.88262295834, -161189.5510424339, 70519.17973166706, -24888.25906389168, 6913.090075739568, -1455.3110985660724, 218.28434343806472, -20.787767883897633, 0.9448424745771409 },
        { 20.73328209262934, -355.39588113301625, 2930.120017080029, -15523.005101104527, 59435.02100055373, -174928.09836457582, 410153.44661443034, -783124.2702459086, 1234808.3845458485, -1622160.7661912946, 1784447.111236311, -1646883.9841012608, 1273986.5170037665, -822885.7607930988, 440653.6786765518, -193461.56459058053, 68489.20435335406, -19075.91689490351, 4025.550900169345, -605.116567369805, 57.74017502657703, -2.629077107949598 },
        { -32.51469387243328, 598.6646414510599, -5259.043194060884, 29379.066390535627, -117313.76498376211, 356534.30199081806, -856577.7217646383, 1666573.4088084865, -2667162.4305086634, 3546107.0799350985, -3939507.317772047, 3665864.3638171917, -2855659.981277241, 1855571.0651226414, -998815.361489997, 440504.27180822997, -156571.4466535625, 43763.99476370752, -9264.769891274975, 1396.6492429231628, -133.61231248004202, 6.098024159260539 },
        { 45.92996638512398, -887.1326887041229, 8150.246121437306, -47414.025633218, 196150.80901058592, -614244.2094344015, 1512703.6568154187, -3003479.625247568, 4887731.469994088, -6589359.941408856, 7406359.792350306, -6960643.114142088, 5468655.743468748, -3579811.95716165, 1939426.9623443792, -860222.4685610705, 307303.46269180987, -86284.2645809471, 18340.439414780834, -2774.93095613841, 266.35064465862035, -12.193010228412472 },
        { -58.70191999375819, 1172.4819882329348, -11129.177612943959, 66791.12223187822, -284450.1419583002, 914601.2645584968, -2306007.1059278874, 4673783.4423515, -7742674.163615888, 10600166.181381904, -12074297.998072416, 11479935.67257921, -9111129.768499956, 6017615.356373953, -3285982.5910321805, 1467756.356214279, -527645.1052230814, 148992.13895219992, -31831.920427781904, 4838.628180510953, -466.40450660326877, 21.433984354029644 },
        { 68.07448566695754, -1393.089688321974, 13548.883590516658, -83296.0810748724, 363185.4862164094, -1194447.1481602232, 3076506.1106569977, -6360006.227425477, 10728254.55238976, -14929356.718764422, 17256568.974609718, -16623785.8881051, 13349485.460640177, -8910303.521571647, 4911884.343933978, -2212833.625302036, 801671.6884373506, -227965.79055226926, 49017.42433479707, -7494.68304383807, 726.3183500504157, -33.54395433693305 },
        { -71.73769767021987, 1494.729979523057, -14808.355482240568, 92767.13671198994, -412232.61944799725, 1381714.2728181218, -3626109.238843948, 7634140.01841671, -13104926.813895836, 18541501.89780487, -21766701.30027714, 21272243.132175017, -17310371.32131557, 11695717.861546196, -6519883.5899206875, 2967547.84729481, -1085272.0734616166, 311297.31768625893, -67471.85053712652, 10392.5993713087, -1014.0414185031939, 47.12849013938811 },
        { 68.71809494718099, -1451.4375702080174, 14585.205252393116, -92729.28764374976, 418416.2507247172, -1424695.0421353735, 3799531.1671584006, -8130582.024872927, 14186660.172290465, -20398617.451702543, 24327499.602247808, -24139490.775311366, 19931232.59893448, -13653220.731812727, 7710456.202172587, -3552387.552109444, 1314022.8263980357, -380939.3759307508, 83389.73824831269, -12963.94948608615, 1275.928470197239, -59.78141478382242 },
        { -59.78141474370307, 1275.9284694278854, -12963.949479226332, 83389.73821030765, -380939.37578404613, 1314022.8259812265, -3552387.5512121436, 7710456.200710583, -13653220.730041604, 19931232.597493842, -24139490.774933778, 24327499.603225008, -20398617.453646492, 14186660.174416795, -8130582.026542592, 3799531.16815463, -1424695.0425907045, 418416.2508832599, -92729.28768452321, 14585.205259715773, -1451.4375710269478, 68.7180949898241 },
        { 47.12849010587304, -1014.0414178616651, 10392.599365607104, -67471.85050571871, 311297.3175660204, -1085272.073124221, 2967547.84658249, -6519883.58880088, 11695717.860280588, -17310371.320471253, 21272243.13236033, -21766701.30166939, 18541501.8999734, -13104926.816096812, 7634140.020083083, -3626109.2398168165, 1381714.2732569117, -412232.6195994137, 92767.13675069084, -14808.355489162102, 1494.729980295248, -71.73769771038981 },
        { -33.54395431206779, 726.3183495754181, -7494.68303963194, 49017.4243117701, -227965.7904649075, 801671.6881955691, -2212833.6248032534, 4911884.343183682, -8910303.520803384, 13349485.460297436, -16623785.888636917, 17256568.976097915, -14929356.720803078, 10728254.554358033, -6360006.228876226, 3076506.1114901775, -1194447.1485319617, 363185.4863437746, -83296.08110726044, 13548.883596290281, -1393.0896889648086, 68.07448570037994 },
        { 21.433984337679274, -466.40450629152025, 4838.628177761853, -31831.920412826577, 148992.1388959955, -527645.1050698272, 1467756.3559065822, -3285982.5905929995, 6017615.355985232, -9111129.768465789, 11479935.67319249, -12074297.99935735, 10600166.183010666, -7742674.165135837, 4673783.443449787, -2306007.1065510293, 914601.2648340665, -284450.14205220516, 66791.1222556582, -11129.177617172998, 1172.4819887030417, -58.701920018195274 },
        { -12.19301021893273, 266.35064447812607, -2774.9309545542537, 18340.439406215544, -86284.26454906313, 307303.4626062203, -860222.4683945226, 1939426.9621205558, -3579811.957003961, 5468655.743558466, -6960643.114646184, 7406359.793269704, -6589359.942516355, 4887731.471003973, -3003479.6259665596, 1512703.657219811, -614244.2096119279, 196150.8090708438, -47414.02564842474, 8150.246124137437, -887.1326890039005, 45.929966400708054 },
        { 6.098024154461817, -133.61231238873322, 1396.6492421259613, -9264.76988698873, 43763.99474789882, -156571.4466118013, 440504.2717297806, -998815.3613913364, 1855571.0650759602, -2855659.9813753692, 3665864.3641421013, -3939507.318320492, 3546107.0805728026, -2667162.4310812526, 1666573.4092116007, -856577.7219900031, 356534.3020891519, -117313.76501704988, 29379.066398911375, -5259.043195546799, 598.664641615875, -32.514693881003396 },
        { -2.6290771058654685, 57.74017498691305, -605.1165670254289, 4025.5508983266836, -19075.91688816525, 68489.20433583453, -193461.5645589008, 440653.6786394027, -822885.7607861847, 1273986.5170672308, -1646883.9842691263, 1784447.111506907, -1622160.7664980588, 1234808.3848185507, -783124.2704362593, 410153.4467204232, -174928.09841059218, 59435.02101610454, -15523.005105007209, 2930.12001777216, -355.395881209733, 20.733282096619845 },
        { 0.9448424738249638, -20.78776786957011, 218.28434331435224, -1455.311097906696, 6913.090073346465, -24888.25905776166, 70519.17972100474, -161189.5510307782, 302227.8826247133, -470109.54973599175, 611075.2214593603, -666489.9463770089, 610728.9005218584, -469502.93775522144, 301506.7196277199, -160508.50759809717, 69986.36177763826, -24537.036606866288, 6715.277040642233, -1358.0502597861273, 180.9061021737111, -11.83084695744537 },
        { -0.2645358710013828, 5.827765955644062, -61.28382446368096, 409.24001168595436, -1947.4922009525787, 7025.496435020473, -19951.98030295733, 45725.06089653756, -85993.54079514179, 134234.23743558695, -175214.6934513394, 192062.79586566667, -177073.88133547985, 137171.42078189802, -88958.4074371902, 47980.71070890675, -21306.433815814533, 7676.1414752016, -2196.828955252902, 483.55159457797953, -74.66031889792117, 5.984002323545968 },
        { 0.04761904771552724, -1.0500000021385343, 11.052631601423885, -73.88888903794235, 352.0588242291773, -1271.8125024733329, 3617.6000068325543, -8305.714300829502, 15653.076950293178, -24494.166706984135, 32065.09095855537, -35271.60005042544, 32658.888931612026, -25436.250029999435, 16611.428588779327, -9044.00000818114, 4069.80000309557, -1496.250000917739, 443.3333335387527, -105.00000003264985, 21.00000000328491, -2.645358704919288 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_22d[23][23] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.6908132500173125, 21.999999995843798, -115.49999995872318, 513.3333330727381, -1828.7499988209438, 5266.799995940349, -12435.499988998276, 24363.428547246996, -39971.24995625796, 55268.88882285441, -64664.59991638618, 64130.18172787827, -53887.16658434596, 38263.07686032139, -22840.71424487944, 11369.59997795088, -4663.312490204234, 1549.0588199716751, -406.3888878664892, 81.05263135433884, -11.549999965069455, 1.0476190440978637, -0.04545454528235591 },
        { 6.212436418588115, -80.03367741560103, 541.1768063242462, -2584.4895091620215, 9526.54943055755, -27988.22235633168, 66951.81388905336, -132386.30980107398, 218691.81245392712, -303997.0328271691, 357181.94763125293, -355451.5579406389, 299533.3970301522, -213200.34763682596, 127530.50352979371, -63595.28882232629, 26124.716635152643, -8690.039088182337, 2282.576823959073, -455.74734222429186, 65.00768046084076, -5.901614465929125, 0.25626792763470224 },
        { -12.574458109543983, 198.91680005689105, -1556.1049307292951, 8068.602254781472, -31060.856345162563, 93700.88495355853, -228159.95942481884, 456922.8852333862, -762045.6008022407, 1067203.686933587, -1261398.810840037, 1261417.6989793396, -1067301.292980435, 762292.8402242035, -457327.21458299, 228636.9558258837, -94133.24145018987, 31373.933041389788, -8255.30902729094, 1650.869236628181, -235.81189823289097, 21.435125734706507, -0.9318654595405219 },
        { 22.626963067695026, -401.8494574633372, 3450.6628927140755, -19138.18931553863, 77079.58570342652, -239666.1940365126, 596148.6870073166, -1212785.5978970057, 2047155.785464855, -2894307.951011233, 3447370.967187799, -3469354.2205761005, 2951120.9422166906, -2117322.7080313833, 1275217.1502209404, -639698.325328055, 264157.861319651, -88273.9006543833, 23281.71114884996, -4665.595923024808, 667.7028647589401, -60.79802087009019, 2.6472543302257696 },
        { -36.5432399627828, 697.9476435328367, -6385.690059676461, 37312.58439736713, -156522.54321747198, 501920.0274605752, -1277938.1520865522, 2646978.4660570268, -4531914.807441945, 6481058.140883809, -7792431.156535224, 7903948.1585773, -6768165.827818173, 4883683.390351976, -2955904.566723542, 1489217.647651821, -617307.220033807, 206985.56003262236, -54756.64066476709, 11002.99297317486, -1578.5391710135164, 144.05624438140893, -6.285267500068814 },
        { 53.32357283371817, -1069.4215151129836, 10235.10781144329, -62252.45483317679, 270308.63183280895, -892137.3537247078, 2325776.8431739835, -4911145.709136383, 8542618.813117245, -12378340.75345352, 15048095.458061121, -15407150.650344416, 13299712.357747354, -9663754.59927731, 5884846.985154109, -2980812.7827212815, 1241500.883747852, -418055.1935373301, 111017.19676626283, -22385.31248501813, 3221.570590060288, -294.8381824657766, 12.897614070293603 },
        { -70.62764773079186, 1465.9563767365682, -14500.552692611243, 90971.70913222784, -406416.4126459919, 1376074.897130388, -3668982.0970881665, 7900072.075844952, -13974377.371986693, 20543747.055054363, -25288169.631718896, 26173506.87489493, -22808162.9885479, 16711115.594483184, -10251542.477942826, 5226743.936758686, -2189711.914836649, 741244.135643512, -197781.44598795183, 40053.04918458622, -5786.971214010935, 531.5368962175023, -23.32906306164484 },
        { 85.1770685294852, -1812.63871427048, 18378.3071724699, -118115.95225424875, 540081.5894149132, -1869302.7415028305, 5087162.790563089, -11161264.230164915, 20081332.055060852, -29974908.910604652, 37402978.87123018, -39185332.630484916, 34519211.52992427, -25538267.038632445, 15803768.535127144, -8121083.252720786, 3426534.1130373715, -1167427.9449382299, 313332.7867905624, -63795.243643944006, 9262.820342905306, -854.6601790956202, 37.66807871992263 },
        { -93.70712592220288, 2031.613822855806, -20990.48105060302, 137484.8547888923, -640619.5225777118, 2258873.703567673, -6259538.6643870855, 13974122.939910784, -25559752.316754274, 38745663.39824668, -49044297.08261831, 52063667.341690436, -46422584.947110936, 34727573.072956905, -21709534.50300199, 11260030.825330913, -4791606.459871127, 1645337.0627770508, -444793.3743827636, 91164.36141970297, -13318.207109219578, 1235.8481921111393, -54.75668683570043 },
        { 94.11532870469354, -2069.5066679872893, 21696.151140579987, -144252.6117046755, 682526.2251198475, -2444335.8520188294, 6880297.013218281, -15601570.748488504, 28979565.01460046, -44595379.89184147, 57274298.044739366, -61649494.76308386, 55696896.79737187, -42184107.16911795, 26678446.83881073, -13987996.003217222, 6012946.948767375, -2084269.2609624972, 568423.6868999437, -117461.71420361924, 17291.661518381272, -1616.0586345653176, 72.08240449134466 },
        { -86.27238462020951, 1917.8308133121566, -20336.74396461985, 136836.2462031825, -655533.0376450157, 2378166.631243916, -6783981.462816756, 15595661.259960767, -29377079.02819287, 45852348.21640791, -59731195.58071897, 65206564.88226604, -59731195.5810254, 45852348.2168939, -29377079.028642893, 15595661.26028306, -6783981.462984008, 2378166.631309114, -655533.0376633012, 136836.24620649926, -20336.743964909278, 1917.8308132925079, -86.27238461468512 },
        { 72.08240449132191, -1616.0586344703008, 17291.661516924345, -117461.7141926415, 568423.686845507, -2084269.260767618, 6012946.94823024, -13987996.002049113, 26678446.83677192, -42184107.166142516, 55696896.79382472, -61649494.759525746, 57274298.04176066, -44595379.88977432, 28979565.013401475, -15601570.747923832, 6880297.012994089, -2444335.8519457253, 682526.2250994488, -144252.61169982827, 21696.15113964706, -2069.5066678528638, 94.1153286941138 },
        { -54.756686831399705, 1235.848191938118, -13318.20710702322, 91164.36140401538, -444793.3743063133, 1645337.0625028687, -4791606.459104462, 11260030.82363103, -21709534.499946892, 34727573.06835849, -46422584.9414156, 52063667.335728265, -49044297.07737535, 38745663.39438944, -25559752.314381078, 13974122.938705886, -6259538.663876724, 2258873.7033926714, -640619.522528693, 137484.85477803755, -20990.48104879263, 2031.6138226440453, -93.70712590871746 },
        { 37.66807871361574, -854.6601788988058, 9262.820340559452, -63795.24362752749, 313332.7867110813, -1167427.94465279, 3426534.1122333105, -8121083.250924629, 15803768.5318618, -25538267.03365485, 34519211.523677625, -39185332.62384426, 37402978.865289114, -29974908.90615504, 20081332.052276608, -11161264.228724176, 5087162.789942836, -1869302.7412878033, 540081.5893545425, -118115.95224106683, 18378.307170349348, -1812.6387140382355, 85.17706851595366 },
        { -23.329063055514126, 531.5368960443033, -5786.971212009661, 40053.04917073828, -197781.44592109826, 741244.1354031453, -2189711.9141561273, 5226743.93523328, -10251542.475152627, 16711115.590197213, -22808162.983137388, 26173506.86909423, -25288169.626479052, 20543747.051096797, -13974377.369490845, 7900072.074542289, -3668982.096522995, 1376074.8969335272, -406416.4125906041, 90971.70912019603, -14500.55269070693, 1465.956376534518, -70.62764771957302 },
        { 12.897614065653409, -294.83818234120093, 3221.5705886459923, -22385.31247531683, 111017.19671946799, -418055.1933688861, 1241500.8832692306, -2980812.7816467993, 5884846.983180659, -9663754.596228184, 13299712.353888558, -15407150.646183228, 15048095.454276573, -12378340.750583304, 8542618.811299536, -4911145.7081829915, 2325776.842758519, -892137.3535795753, 270308.6317918921, -62252.454824307984, 10235.107810052265, -1069.4215149680576, 53.323572825906844 },
        { -6.285267497218945, 144.0562443070576, -1578.5391701780613, 11002.992967493907, -54756.64063734959, 206985.55993379315, -617307.2197523372, 1489217.6470195919, -2955904.5655584466, 4883683.388542471, -6768165.825526973, 7903948.1560953865, -7792431.1542654075, 6481058.139160016, -4531914.806347708, 2646978.465481302, -1277938.1518350374, 501920.0273725016, -156522.5431925934, 37312.584391979515, -6385.690058836159, 697.9476434462802, -36.543239958209625 },
        { 2.647254328798123, -60.79802083344541, 667.7028643495635, -4665.595920266962, 23281.711135519694, -88273.9006062558, 264157.8611824206, -639698.325019799, 1275217.1496511013, -2117322.707142067, 2951120.9410913656, -3469354.2193526034, 3447370.9660634873, -2894307.950157835, 2047155.7849223916, -1212785.597611008, 596148.6868822176, -239666.19399260046, 77079.58569100028, -19138.189312848303, 3450.6628922959962, -401.84945742059057, 22.626963065468065 },
        { -0.9318654589685254, 21.435125720155977, -235.81189807083496, 1650.8692355466446, -8255.30902205258, 31373.933022445635, -94133.24139615588, 228636.9557045301, -457327.21435800445, 762292.8398715258, -1067301.2925347015, 1261417.6984932607, -1261398.8103915257, 1067203.6865937042, -762045.6005860062, 456922.8851192337, -228159.95937486365, 93700.88493598127, -31060.856340180846, 8068.602253702804, -1556.1049305620793, 198.9168000398776, -12.574458108666542 },
        { 0.2562679274618875, -5.901614461553719, 65.00768041218082, -455.74734190226985, 2282.5768223961295, -8690.03908252156, 26124.716619009567, -63595.288786078665, 127530.50346242252, -213200.34753082323, 299533.3968963544, -355451.55779438926, 357181.94749585673, -303997.03272476833, 218691.81238874057, -132386.30976663413, 66951.81387398088, -27988.22235101686, 9526.549429049346, -2584.4895088353837, 541.1768062736928, -80.03367741047401, 6.212436418325578 },
        { -0.04545454524967751, 1.0476190432724397, -11.549999955895569, 81.05263129402204, -406.3888875732393, 1549.0588189083408, -4663.312487172909, 11369.599971145513, -22840.714232206552, 38263.07684032632, -53887.16655913507, 64130.18170027575, -64664.5998907702, 55268.888803514164, -39971.249943941344, 24363.428540736877, -12435.499986149372, 5266.799994934114, -1828.7499985351415, 513.3333330108275, -115.49999994915122, 21.999999994874997, -2.6908132499679387 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_23d[24][24] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.7342915124645377, 23.000000032352272, -126.5000003626155, 590.3333359200859, -2213.750013166813, 6729.800050915371, -16824.500155282218, 35022.42895423245, -61289.25077688418, 90798.89020046439, -114406.60186035036, 122916.1840384841, -112673.1689100443, 88005.07883739198, -58370.71566261275, 32687.60083130779, -15322.312917180883, 5938.05899594573, -1869.3889465417415, 466.05264677310146, -88.55000303942083, 12.047619482029004, -1.0454545849790575, 0.04347826258467729 },
        { 6.434987591844978, -85.49456466980953, 602.4701067234208, -3017.2493919653734, 11700.414406043852, -36272.82985562684, 91854.69146323197, -192951.266238159, 339953.1138401104, -506271.08004987316, 640559.4931408478, -690540.8386570774, 634780.5377294641, -496984.4731809889, 330303.1519670371, -185295.22639261562, 86990.62737010459, -33758.27757926773, 10640.379525548997, -2655.575540375634, 505.0465903728442, -68.77379926078717, 5.97270582066449, -0.24857196519765443 },
        { -13.314542426605916, 217.60400255200378, -1770.9514754887161, 9608.160134302185, -38866.92433966712, 123637.13542893762, -318550.0547777188, 677493.3047514642, -1204812.2820742945, 1807304.4325753208, -2299998.442819675, 2491265.348655009, -2299182.5754580763, 1806124.4015549074, -1203829.0513649473, 677013.5576548267, -318530.8781365857, 123849.43416338591, -39103.24513985452, 9774.131470374128, -1861.4372727971327, 253.79351330380285, -22.065817207876382, 0.9192839754245569 },
        { 24.557666844810054, -451.22097928860615, 4028.7341594626314, -23345.20374059842, 98661.73676578414, -323160.62034663756, 849936.6984575555, -1835303.8069618966, 3301971.706019598, -4998877.610132615, 6409049.54238949, -6984685.819220689, 6479364.9430115195, -5112172.531551886, 3420247.0722684423, -1929799.275906708, 910572.6380992596, -354945.36256548046, 112321.86590400791, -28132.73510916959, 5367.569612457323, -733.0451220168867, 63.830248731328155, -2.6629085775691936 },
        { -40.76229142042763, 806.3537452693707, -7670.742943049211, 46789.76951516957, -205721.33187074488, 694155.2833037649, -1867043.8970282516, 4101739.5023102863, -7480680.5314333895, 11449887.535350027, -14812657.191019278, 16264905.413990019, -15184567.169019885, 12046090.989623502, -8097522.933046853, 4587787.235396912, -2172650.083001428, 849657.1744834876, -269652.5230995403, 67714.77023796544, -12950.0626693015, 1772.36813704364, -154.63129082121972, 6.462544114184287 },
        { 61.29950888867902, -1274.4899297455197, 12685.02875037965, -80508.33686559524, 366095.5679127261, -1270149.533172517, 3494520.453447126, -7819755.93753567, 14478133.586944433, -22438664.158947736, 29334491.962233666, -32498136.183886446, 30571864.497265667, -24413805.046565607, 16506301.346919114, -9399624.90032817, 4471544.977472499, -1755748.4853543227, 559236.5930546415, -140894.61760130725, 27025.3378481798, -3708.746727858422, 324.3730526421606, -13.58743086975648 },
        { -83.91746560175238, 1807.0960270951427, -18594.519832821577, 121710.25807231119, -569135.8996624412, 2024124.419843433, -5690395.272308748, 12972234.866845824, -24403038.289700076, 38340128.40129746, -50715302.77145162, 56759963.76190593, -53872172.12092785, 43357800.5748379, -29517360.488744862, 16912306.98031957, -8089716.676744626, 3192134.353865618, -1021294.5789662075, 258349.54779985192, -49737.819324511715, 6848.712886749796, -600.85956060044, 25.24097489828817 },
        { 104.92551909897954, -2318.1133731841446, 24457.70417991685, -164000.8290325478, 784683.5751128168, -2851175.314514229, 8175104.889264804, -18973013.56477941, 36269395.13582107, -57805446.19615783, 77443241.352694, -87660387.32626997, 84043924.81927566, -68253298.61926936, 46842985.45659042, -27035248.24682525, 13017185.47941692, -5167211.009699417, 1662208.9069337451, -422569.8093941567, 81724.91836702131, -11300.436105971594, 995.2609245326275, -41.9587337205485 },
        { -120.08049941075069, 2704.2632610293454, -29084.942636178257, 198782.91973422133, -969100.1979944196, 3586024.4252991187, -10463729.470094465, 24691369.066800643, -47942058.96953914, 77522514.76854888, -105251845.21970381, 120601503.25197235, -116923451.86135648, 95927380.54945575, -66451161.74134787, 38679456.03201801, -18769271.080526166, 7503911.080181163, -2429788.2952008857, 621454.0084037523, -120862.69445607894, 16798.878099035774, -1486.6456262030988, 62.955312574163045 },
        { 125.92758764019085, -2877.708917489465, 31415.939847473346, -217995.38022308104, 1079159.1449826416, -4055014.472195034, 12013955.008697262, -28778094.165024705, 56700318.93899342, -92987477.97422545, 127961886.79324453, -148507832.55711958, 145719088.82385194, -120904758.42446877, 84637601.04676187, -49749467.3440761, 24361711.341236524, -9822569.682549203, 3205738.103665345, -825954.103730495, 161737.53419439704, -22624.17273829462, 2014.153875772944, -85.77178642390271 },
        { -121.03772214055792, 2797.467291127235, -30900.648460435852, 217038.69565452548, -1087946.2063350403, 4140823.0511864675, -12429865.465980785, 30172296.066773992, -60247061.65802103, 100131112.2437217, -139623281.85452965, 164152016.0246995, -163107451.65743038, 136982562.54045713, -97012578.50848536, 57657917.714357585, -28532556.583896946, 11619228.541725934, -3827909.288503106, 995042.4497473966, -196485.209672359, 27702.44403616614, -2484.6746359539065, 106.55411351550444 },
        { 106.55411310679447, -2484.6746272539986, 27702.443948464534, -196485.20911561348, 995042.4472655258, -3827909.2802616223, 11619228.520702403, -28532556.542152435, 57657917.64984709, -97012578.43352866, 136982562.48147553, -163107451.64258453, 164152016.06489018, -139623281.93487734, 100131112.33392793, -60247061.73161387, 30172296.11305501, -12429865.488849264, 4140823.060037723, -1087946.2089753565, 217038.6962424383, -30900.64855252847, 2797.4673002129634, -121.03772256569937 },
        { -85.771786070638, 2014.153868285021, -22624.172663266247, 161737.53372100863, -825954.1016375055, 3205738.0967892758, -9822569.665265681, 24361711.307691667, -49749467.29406051, 84637600.99281909, -120904758.39031024, 145719088.83292478, -148507832.6157283, 127961886.88445722, -92987478.06888846, 56700319.01325598, -28778094.210684028, 12013955.030906225, -4055014.4806987545, 1079159.147498612, -217995.3807796517, 31415.939934217968, -2877.7089260066446, 125.92758803728826 },
        { 62.9553122996263, -1486.6456204091687, 16798.878041355903, -120862.69409451862, 621454.0068193498, -2429788.2900562296, 7503911.067464315, -18769271.05649791, 38679455.99775286, -66451161.708134286, 95927380.53640534, -116923451.88596298, 120601503.31665611, -105251845.30801867, 77522514.8554773, -47942059.035776295, 24691369.106811363, -10463729.489306103, 3586024.4325893535, -969100.2001364996, 198782.9202054063, -29084.942709291085, 2704.263268178495, -120.08049974300123 },
        { -41.95873352902287, 995.2609205078271, -11300.436066170063, 81724.91811922961, -422569.8083183556, 1662208.903483381, -5167211.00132718, 13017185.464078622, -27035248.22612082, 46842985.43948054, -68253298.6195588, 84043924.8486407, -87660387.38470195, 77443241.42640416, -57805446.26607704, 36269395.187941745, -18973013.595833424, 8175104.904019335, -2851175.3200719897, 784683.5767364796, -164000.8293879854, 24457.704234861318, -2318.1133785378597, 104.92551934710706 },
        { 25.24097477879472, -600.8595580992901, 6848.712862178541, -49737.81917261055, 258349.54714645472, -1021294.5768967237, 3192134.34894325, -8089716.668032849, 16912306.969319243, -29517360.481705133, 43357800.58065941, -53872172.1465585, 56759963.80635018, -50715302.82468282, 38340128.45048103, -24403038.325755816, 12972234.888101498, -5690395.282321904, 2024124.423592726, -569135.9007526113, 121710.25831000438, -18594.519869449327, 1807.096030653387, -83.91746576629137 },
        { -13.587430803535016, 324.37305126080173, -3708.7467143735403, 27025.337765403558, -140894.61724833434, 559236.5919503493, -1755748.4827819273, 4471544.973086759, -9399624.895214243, 16506301.34488131, -24413805.052688994, 30571864.515219294, -32498136.212631058, 29334491.99544565, -22438664.189066492, 14478133.608741391, -7819755.950280434, 3494520.459410012, -1270149.5353945352, 366095.5685563549, -80508.33700546317, 12685.028771877745, -1274.489931828588, 61.29950898482995 },
        { 6.4625440819518705, -154.6312901506877, 1772.368130536348, -12950.062629633268, 67714.77007009178, -269652.5225804083, 849657.1732994661, -2172650.0810596, 4587787.233333186, -8097522.932862054, 12046090.993860474, -15184567.179386662, 16264905.429780103, -14812657.208794476, 11449887.551261209, -7480680.54283349, 4101739.5089333327, -1867043.9001103372, 694155.2844478728, -205721.33220114931, 46789.769586776136, -7670.7429540328785, 806.3537463312649, -40.76229146937637 },
        { -2.662908564044108, 63.830248450517495, -733.0451193062349, 5367.56959604146, -28132.735040121283, 112321.86569272797, -354945.3620934124, 910572.6373542614, -1929799.275193558, 3420247.072480706, -5112172.533780868, 6479364.947948645, -6984685.826501431, 6409049.550427458, -4998877.617264854, 3301971.711089947, -1835303.8098926784, 849936.6998157776, -323160.6208492931, 98661.73691060937, -23345.20377191706, 4028.734164258838, -451.22097975140997, 24.557666866122883 },
        { 0.9192839706893651, -22.065817109689586, 253.79351236042373, -1861.43726711767, 9774.131446593017, -39103.24506775353, 123849.43400533011, -318530.87789598166, 677013.5574490861, -1203829.0515225434, 1806124.402464659, -2299182.577356168, 2491265.351395317, -2299998.4458006755, 1807304.43520549, -1204812.2839328472, 677493.305821458, -318550.05527205137, 123637.13561144887, -38866.92439216203, 9608.160145634705, -1770.951477222031, 217.60400271898715, -13.31454243429094 },
        { -0.24857196390374353, 5.972705793855034, -68.77379900419048, 505.0465888357208, -2655.5755339593256, 10640.379506242161, -33758.27753763566, 86990.62730869488, -185295.22634575612, 330303.1520278349, -496984.473457049, 634780.5382844196, -690540.8394472447, 640559.4939910248, -506271.0807973821, 339953.1143659388, -192951.26653995755, 91854.6916023485, -36272.82990689845, 11700.414420772828, -3017.249395140875, 602.4701072086555, -85.49456471649519, 6.43498759399276 },
        { 0.04347826235668679, -1.0454545802571449, 12.04761943696471, -88.55000277048491, 466.05264565272074, -1869.3889431894993, 5938.058988808969, -15322.312906911478, 32687.60082423499, -58370.715675568084, 88005.07888949823, -112673.16901243676, 122916.18418300715, -114406.60201466274, 90798.8903358645, -61289.250871829994, 35022.4290086077, -16824.50018030873, 6729.800060127493, -2213.750015811047, 590.3333364896442, -126.50000044958911, 23.00000004071228, -2.7342915128490586 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_24d[25][25] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.775958174890156, 23.99999993215815, -137.99999922989096, 674.6666610897288, -2656.4999710716174, 8500.79988568824, -22432.66630896975, 49443.42766167834, -91933.87308876141, 145278.21886020785, -196125.5950114815, 226922.17552783003, -225346.3265973008, 192011.07077343384, -140089.70949954202, 87166.93017219694, -45966.9357403964, 20359.0580038146, -7477.555240064817, 2237.0525331660433, -531.2999756180377, 96.38094778304715, -12.545453925172874, 1.0434782074733115, -0.041666664473829426 },
        { 6.651982852441906, -91.03929616953369, 667.4759508130124, -3497.8824158874486, 14234.911972896882, -46438.758189495486, 124107.25601429888, -275999.3390955633, 516612.37702230376, -820586.0753242872, 1112339.0391242532, -1291309.0869467177, 1285904.4478177913, -1098250.6040852678, 802881.0536309418, -500436.6875669173, 264301.87143165956, -117217.24386449659, 43103.01014604846, -12908.734314324098, 3068.742288677261, -557.1668540925017, 72.58045520496687, -6.041241405371653, 0.24138765514407062 },
        { -14.050755380957469, 236.95067744374813, -2003.063404971086, 11348.690267042317, -48126.71654588745, 160999.7621213003, -437590.81581068644, 984987.25839762, -1860517.6921516575, 2976228.2570357877, -4057323.2309493353, 4732020.766570309, -4730467.262087539, 4053383.9344171155, -2971567.893959389, 1856690.2127304687, -982685.3902491266, 436637.5365046109, -160828.0903585807, 48237.682935043355, -11482.774327754481, 2087.3714571766136, -272.21635236824545, 22.680834205503913, -0.9070885272060158 },
        { 26.52216835448351, -503.4989521742561, 4667.124599561478, -28203.618603765983, 124797.40363607288, -429490.4273408564, 1190843.6829460175, -2720211.106310684, 5196330.171769149, -8386679.793031684, 11515591.230235348, -13510454.025839722, 13573409.47534713, -11679967.231883239, 8593950.761337766, -5386715.266431694, 2858960.2794371434, -1273457.4411418529, 470087.20783973974, -141272.4853188113, 33689.03431749326, -6133.9442300824585, 801.1062080687249, -66.83688541428708, 2.6763342386905307 },
        { -45.164293827866615, 924.0732597804714, -9125.762654820139, 58005.40426179853, -266740.0833236553, 944741.9725380199, -2676644.965864491, 6216524.765039299, -12031548.941256925, 19624110.48212573, -27179599.54823359, 32119084.032264113, -32466687.148106653, 28084537.59343833, -20758263.269137118, 13063128.806279713, -6957486.879420452, 3108707.005980586, -1150751.951157723, 346694.6645132705, -82862.91356889594, 15118.321069623713, -1978.188909772582, 165.32534221555065, -6.630541819302986 },
        { 69.85427194774826, -1503.4573327283845, 15537.079386657666, -102714.44581285992, 488145.5619293218, -1776114.794429438, 5142883.581318275, -12156816.556168674, 23869890.235587236, -39399936.72057947, 55117117.37748954, -65687936.891960494, 66882915.837078184, -58220598.5235018, 43270085.68038803, -27361930.14165779, 14635830.876714371, -6564632.817297071, 2438419.001695246, -736926.9933888068, 176629.3713832851, -32308.957930728982, 4237.491307369235, -354.9103935391488, 14.262408065685955 },
        { -98.60889027919585, 2199.766303808032, -23508.129049086234, 160253.03984695472, -782794.8818553621, 2917590.8028452285, -8625466.600528592, 20754352.383077387, -41372952.21363593, 69180510.8449143, -97860425.74893425, 117757269.36279194, -120909745.76732437, 106028014.65805502, -79315269.92936991, 50446053.31707165, -27123354.887898866, 12222361.145371456, -4559074.388292743, 1383081.8311340576, -332655.5145148412, 61042.85456464786, -8029.489673253104, 674.3189454160929, -27.165549374415058 },
        { 127.48788633546371, -2919.574465592426, 32001.51728216387, -223484.1724127214, 1116674.8083247002, -4250005.520674492, 12806140.512614563, -31345906.228135493, 63447543.94911662, -107537189.40243597, 153952407.03310198, -187232649.29709485, 194069595.9376556, -171623511.51523966, 129357374.50154592, -82834256.02897921, 44811430.26674988, -20305544.891068913, 7612607.583703238, -2320126.893110255, 560400.2597053339, -103235.78227316373, 13628.369942803429, -1148.3253300264787, 46.404182525849045 },
        { -151.31239609248635, 3534.0804844307536, -39500.54360833261, 281190.73659384233, -1431418.2802438417, 5546224.958315191, -16998196.659234047, 42275668.283725426, -86847659.90860862, 149220264.93888447, -216311592.1935152, 266085533.1986283, -278676372.61823463, 248781471.46870843, -189132563.2420783, 122065265.90243423, -66509858.1794701, 30336577.573013477, -11442155.551949415, 3506721.1121543683, -851368.1954686044, 157584.21745657185, -20894.90637548065, 1767.8322371087656, -71.71193477729426 },
        { 165.101555468064, -3914.7259698725193, 44427.117045870706, -321143.4380229685, 1659987.8010022563, -6529986.046626379, 20313055.199864227, -51256137.81568168, 106774877.65097341, -185918038.32619113, 272928929.52595884, -339735074.2311372, 359778846.3828606, -324520228.79617316, 249093837.4981672, -162204892.65247068, 89115925.61240286, -40961559.17220723, 15560448.169347329, -4800686.420328914, 1172760.6446719475, -218330.10240066887, 29106.166317821648, -2475.0175934882986, 100.87492961746896 },
        { -165.71219999709385, 3975.556058657399, -45664.19310450611, 334180.24996296753, -1749216.6653012398, 6969238.7680558255, -21959826.523201603, 56129303.224900566, -118432648.99886167, 208836927.20653185, -310384561.16956544, 391018441.5294599, -418897187.5009523, 382043999.37571955, -296349854.7106064, 194912593.8906601, -108101043.1001685, 50132476.489523165, -19204844.309555575, 5972090.375668426, -1469828.4995012602, 275560.581764739, -36979.29881081999, 3164.156080622062, -129.72265022997763 },
        { 152.96510711193477, -3703.788795681534, 42953.245281109936, -317492.4864812187, 1679135.725042888, -6761873.702179501, 21542139.30798541, -55686537.07923994, 118859312.03948632, -212052394.06436166, 318896609.527177, -406502652.0650556, 440608701.81224453, -406502652.2781348, 318896609.8626505, -212052394.4014906, 118859312.29410642, -55686537.230194494, 21542139.37907091, -6761873.728641004, 1679135.7326835617, -317492.48813437694, 42953.24553377, -3703.7888200068437, 152.96510822418517 },
        { -129.72264926629546, 3164.156059697368, -36979.298595232125, 275560.5803686674, -1469828.4931331926, 5972090.354015253, -19204844.252873566, 50132476.373531535, -108101042.91568208, 194912593.6715472, -296349854.5425298, 382043999.364423, -418897187.7082935, 391018441.92422867, -310384561.64060813, 208836927.6296663, -118432649.29948704, 56129303.39649852, -21959826.60193481, 6969238.796815569, -1749216.6734897182, 334180.2517160907, -45664.19337021806, 3975.556084071378, -165.71220115241965 },
        { 100.87492886603978, -2475.0175773182373, 29106.16615287056, -218330.10134621704, 1172760.6399413852, -4800686.404630842, 15560448.129734484, -40961559.09554486, 89115925.50215939, -162204892.54958457, 249093837.48118895, -324520228.9485138, 359778846.73740005, -339735074.7345529, 272928930.0610092, -185918038.77795503, 106774877.9597917, -51256137.98742163, 20313055.277182277, -6529986.074472253, 1659987.8088446194, -321143.4396878208, 44427.117296504824, -3914.725993715701, 165.1015565469437 },
        { -71.71193425056721, 1767.8322258998412, -20894.90626252687, 157584.21674615674, -851368.1923485395, 3506721.1021363153, -11442155.528007215, 30336577.530738164, -66509858.130130485, 122065265.88683298, -189132563.32493818, 248781471.70921323, -278676373.02686375, 266085533.7140081, -216311592.70779163, 149220265.35661486, -86847660.18679851, 42275668.43557289, -16998196.726630278, 5546224.982327142, -1431418.2869489028, 281190.73800753837, -39500.54381999351, 3534.0805044776052, -151.3123969961719 },
        { 46.40418219469667, -1148.325323075621, 13628.369873795718, -103235.78184798748, 560400.2578891305, -2320126.887539107, 7612607.571482851, -20305544.872955505, 44811430.256362624, -82834256.0608976, 129357374.62349847, -171623511.7649064, 194069596.31252524, -187232649.74096894, 153952407.45896414, -107537189.73945397, 63447544.16943365, -31345906.346755117, 12806140.564691564, -4250005.53907477, 1116674.8134282238, -223484.1734827824, 32001.517441665044, -2919.574480644322, 127.48788701190315 },
        { -27.165549188395975, 674.3189415762082, -8029.489635811879, 61042.85433991571, -332655.51358982344, 1383081.8284766073, -4559074.383272486, 12222361.140702054, -27123354.895489443, 50446053.36212657, -79315270.04320775, 106028014.86211418, -120909746.05441795, 117757269.68997979, -97860426.05463345, 69180511.08243948, -41372952.36681538, 20754352.46470769, -8625466.636063624, 2917590.81532007, -782794.8852969744, 160253.04056530553, -23508.129155777857, 2199.7663138464086, -98.6088907291929 },
        { 14.26240797288254, -354.91039166114325, 4237.491289446434, -32308.95782665903, 176629.37097613883, -736926.9923295062, 2438419.0002345624, -6564632.818084892, 14635830.888106326, -27361930.17948157, 43270085.76277754, -58220598.66129059, 66882916.023500636, -65687937.09920833, 55117117.56750847, -39399936.866276376, 23869890.328590963, -12156816.605347898, 5142883.602585346, -1776114.8018580808, 488145.56397013884, -102714.4462372693, 15537.079449509285, -1503.4573386277011, 69.8542722116553 },
        { -6.63054177857521, 165.32534141007065, -1978.188902275754, 15118.321027869324, -82862.91341675985, 346694.66417701775, -1150751.951021597, 3108707.0078376043, -6957486.888106033, 13063128.830308441, -20758263.317661025, 28084537.67127285, -32466687.250786744, 32119084.14451734, -27179599.649736304, 19624110.55920149, -12031548.990073154, 6216524.790701104, -2676644.976904625, 944741.9763793467, -266740.08437546645, 58005.40447988817, -9125.762687041806, 924.0732627990664, -45.164293962674954 },
        { 2.676334223217134, -66.83688511595632, 801.106205369979, -6133.944215805726, 33689.034270494674, -141272.48524281158, 470087.2079914737, -1273457.442458722, 2858960.2842262513, -5386715.278559539, 8593950.784755424, -11679967.268442662, 13573409.522764858, -13510454.077082753, 11515591.276091848, -8386679.827606866, 5196330.193535112, -2720211.1177016995, 1190843.6878273145, -429490.4290341189, 124797.40409852577, -28203.61869942926, 4667.124613668675, -503.49895349392483, 26.522168413337248 },
        { -0.907088522263645, 22.680834112720955, -272.2163515544897, 2087.3714531287583, -11482.774316245765, 48237.68292739145, -160828.09047248028, 436637.5371227879, -982685.3922590694, 1856690.2175705994, -2971567.903042493, 4053383.9483412066, -4730467.279938737, 4732020.785707453, -4057323.2479422637, 2976228.269782938, -1860517.70013898, 984987.2625637583, -437590.8175907103, 160999.76273732886, -48126.716713807065, 11348.69030171499, -2003.06341007657, 236.95067792083483, -14.05075540221054 },
        { 0.2413876538974378, -6.04124138256519, 72.58045501112187, -557.1668531927261, 3068.7422866062616, -12908.734316313221, 43103.01019021914, -117217.24406725161, 264301.8720522167, -500436.68901620357, 802881.0563006332, -1098250.608127547, 1285904.4529593943, -1291309.0924284183, 1112339.0439642174, -820586.0789419515, 516612.3792812311, -275999.340270939, 124107.25651542433, -46438.75836262208, 14234.912020021644, -3497.882425604684, 667.475952242235, -91.0392963029887, 6.651982858381869 },
        { -0.041666664267721996, 1.043478203785299, -12.545453894699381, 96.38094765103055, -531.299975390795, 2237.0525340349413, -7477.55524949657, 20359.058043814435, -45966.93585867759, 87166.93044334397, -140089.70999316173, 192011.07151485095, -225346.32753551487, 226922.17652449606, -196125.59588805502, 145278.21951384834, -91933.87349591374, 49443.42787317699, -22432.66639901364, 8500.799916758355, -2656.4999795206677, 674.6666628302887, -137.99999948568927, 23.999999956031772, -2.7759581759520904 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_25d[26][26] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.8159581756577623, 24.99999994633375, -149.9999993413628, 766.6666614894543, -3162.4999708504115, 10625.999874583027, -29516.666237904057, 68671.42737898347, -135196.87224735605, 226997.2168870661, -326875.99124407745, 405218.16954629193, -433358.3186378932, 400023.0617996169, -318385.7009809651, 217917.32330919456, -127685.93104229058, 63622.055310583135, -26705.55394955389, 9321.052022561196, -2656.4998118437893, 602.3809061814387, -104.54544587193381, 13.043477094557554, -1.0416665663448688, 0.039999995836728926 },
        { 6.8637226018569635, -96.66448811247982, 736.2369267159283, -4029.1924297168707, 17169.463866115755, -58796.27343020634, 165372.7498013508, -388151.08457069, 769202.0910385015, -1298068.009683727, 1876784.5017657722, -2334266.936094898, 2503208.417655293, -2315996.1034609075, 1846988.3551762663, -1266322.7916125811, 743094.3921942634, -370748.86524964886, 155804.79857867432, -54437.40222820966, 15529.223694781875, -3524.353897411582, 612.1361573235276, -76.42607791051763, 6.107402869065322, -0.23466315725954343 },
        { -14.782823469720777, 256.94072642165946, -2252.900216165982, 13305.296242577633, -59024.788445542246, 207151.66887131432, -592327.1553744202, 1406796.250851456, -2812733.6434401055, 4779583.274664679, -6948844.764313906, 8681966.42689385, -9345583.451168543, 8674348.7995283, -6936726.944460693, 4767246.038893478, -2803308.2235837486, 1401213.0576842201, -589812.6666033714, 206378.7562321039, -58950.60524715156, 13394.749669144287, -2329.01744811703, 291.06840976399855, -23.281080571534826, 0.8952680757359369 },
        { 28.517550784819598, -558.6704028745843, 5368.588235790193, -33775.50465320907, 156161.24202069727, -563354.6064887486, 1642325.2747477903, -3956629.75670166, 7997768.812964588, -13708083.240029855, 20069179.077157352, -25219443.909178752, 27278564.789789286, -25423575.78198964, 20402855.48439839, -14065030.77009969, 8293109.768283052, -4155172.002004548, 1752766.4884527486, -614475.3527728341, 175823.0085755683, -40012.88820482991, 6967.15067065729, -871.8500389019885, 69.81805117481582, -2.687785823875812 },
        { -49.741996742183765, 1051.2808420919946, -10762.392929879965, 71166.51251653311, -341624.3617769604, 1267206.8711656893, -3772114.056170877, 9234364.814147528, -18902817.43116695, 32729807.40653257, -48318761.66137919, 61142445.23164002, -66525278.31991324, 62315246.28648825, -50228260.901236, 34758338.534985065, -20563661.13508392, 10334108.336224407, -4370903.207512637, 1536022.512841899, -440468.08764153376, 100437.90542321239, -17520.103846840022, 2196.0446538422784, -176.1274766057379, 6.789892408063991 },
        { 78.98336265047105, -1757.4023087010619, 18829.490513554152, -129450.15205401466, 641759.605990549, -2443540.1443439326, 7428126.036580671, -18495251.579250574, 38386671.86474177, -67228814.15103948, 100202541.36985031, -127827409.85806394, 140050095.82550985, -131978064.78912319, 106939035.77815667, -74345653.68812364, 44165031.253902495, -22276227.746043056, 9452968.20554111, -3331840.1538854768, 958011.9404612996, -218987.91155366774, 38285.513142487915, -4808.776403190508, 386.40772392845884, -14.92259769110706 },
        { -114.73500318265742, 2647.8222696634643, -29344.172407848564, 207990.87498218266, -1059352.0481902568, 4129178.239478841, -12806588.375972351, 32435158.877963115, -68300073.21264583, 121102651.75124356, -182420116.04831013, 234849231.6843418, -259361604.90492353, 246124886.52098548, -200662666.37253538, 140269797.99082658, -83736128.43521658, 42421535.30305188, -18073339.639381148, 6393225.62400267, -1844308.1575195545, 422851.4953829137, -74131.11376784336, 9334.790318851456, -751.8581811528169, 29.0991311651535 },
        { 153.02474457592635, -3627.396621656618, 41243.679018578056, -299476.0591321787, 1559839.0541744514, -6205617.9382887455, 19604743.83566952, -50475874.44838062, 107847860.20003475, -193697582.4468324, 295099012.96852833, -383741637.96758264, 427581839.82788616, -408988439.5712385, 335816042.5949732, -236246856.7778111, 141844255.47201276, -72235042.20087843, 30921344.701044627, -10985493.514155773, 3181671.5340886726, -732138.3423879537, 128785.2309195614, -16267.495371462031, 1314.0280301707476, -50.99333078219724 },
        { -187.85814259729253, 4543.912744136207, -52697.902055364306, 390079.3182579593, -2069663.1642696587, 8379821.27865983, -26914139.7158785, 70367075.19265983, -152489102.43003017, 277440102.365048, -427687606.1459354, 562135625.977799, -632461768.638968, 610310063.8651651, -505147138.6809761, 357972710.5663246, -216365446.81226984, 110859227.02618477, -47721334.66062691, 17041599.33327626, -4959178.660500805, 1146189.5686119115, -202441.44275788273, 25668.426372512953, -2080.730096722678, 81.0130943470065 },
        { 212.6264758396213, -5223.395688799991, 61526.34944953147, -462520.4481184169, 2491751.6869929275, -10240768.806430489, 33372215.00510475, -88480165.2006507, 194316559.17890477, -358034405.6270243, 558516575.1503696, -742276872.5352842, 843800206.2339381, -822079140.7768649, 686488975.3171896, -490493833.6763204, 298728433.5590829, -154143116.7111193, 66789437.57698069, -23996457.135800242, 7022708.555385712, -1631707.6351941547, 289616.99793133436, -36891.280990753985, 3003.4010988727973, -117.41133178047694 },
        { -222.07812321612843, 5522.037184691963, -65850.59341269328, 501251.04468420596, -2734661.8215114474, 11382174.984663315, -37562754.65815939, 100843356.42799559, -224207999.02492848, 418098896.536863, -659844100.2399762, 886810314.9505533, -1018944260.9927487, 1002866406.5303538, -845567489.259744, 609677894.6653794, -374513707.5307135, 194813964.8020974, -85054954.86125632, 30777804.946509555, -9067943.984115265, 2120251.387718645, -378572.36128692655, 48492.971771058925, -3968.804268092163, 155.9260739438251 },
        { 214.0749861351688, -5374.229513343648, 64723.830891758866, -497705.4457886692, 2743780.2652347214, -11542588.423490904, 38508363.605790794, -104527764.25750595, 234998315.56430137, -443135130.95080584, 707172036.0786201, -960929680.8606299, 1116110411.4561632, -1110159839.158847, 945675478.1142554, -688641304.4521271, 427064877.8801462, -224185300.2055209, 98735194.8115569, -36026347.344048835, 10698665.922163012, -2520457.0857502264, 453263.94349507795, -58457.13978267085, 4815.357753966176, -190.3526687630739 },
        { -190.3526751932474, 4815.357899395645, -58457.14135309425, 453263.9542429703, -2520457.137958173, 10698666.112995323, -36026347.88666723, 98735196.03406024, -224185302.39608732, 427064880.9655873, -688641307.7076458, 945675480.2668705, -1110159839.0047503, 1116110408.636608, -960929676.1591271, 707172030.9558384, -443135126.70023644, 234998312.75789675, -104527762.76180986, 38508362.96271635, -11542588.202591097, 2743780.205882001, -497705.4337440324, 64723.829152323924, -5374.229353819147, 214.07497913965125 },
        { 155.92607927354152, -3968.8043874476275, 48492.97304486197, -378572.36987882206, 2120251.428693382, -9067944.130334219, 30777805.348804537, -85054955.72555244, 194813966.23727602, -374513709.2850238, 609677895.9428916, -845567488.9238507, 1002866403.7190794, -1018944255.7616341, 886810308.3928022, -659844093.9121903, 418098891.63149756, -224207995.92416844, 100843354.82484601, -37562753.984179966, 11382174.757130135, -2734661.761214743, 501251.03258569806, -65850.59168184051, 5522.0370272191285, -222.07811635765225 },
        { -117.4113357638269, 3003.401187031756, -36891.28191837054, 289617.00407573296, -1631707.663806257, 7022708.654205495, -23996457.394921552, 66789438.09261346, -154143117.450925, 298728434.1683011, -490493833.3887667, 686488973.2130015, -822079136.3306968, 843800199.7951552, -742276865.3091332, 558516568.6021845, -358034400.7532419, 194316556.18477425, -88480163.68504307, 33372214.378283072, -10240768.597567806, 2491751.632233187, -462520.4372292763, 61526.34790345062, -5223.395549059643, 212.6264697877987 },
        { 81.01309702933058, -2080.730155264119, 25668.426978090458, -202441.44667933127, 1146189.5863084253, -4959178.718878922, 17041599.47532866, -47721334.90618107, 110859227.26473345, -216365446.6754424, 357972709.40400356, -505147135.8196799, 610310059.0440841, -632461762.3324541, 562135619.3004997, -427687600.31943107, 277440098.1425355, -152489099.88682586, 70367073.92487104, -26914139.197943788, 8379821.107800551, -2069663.1198476458, 390079.30948778143, -52697.90081771363, 4543.912632875133, -187.85813780127017 },
        { -50.99333240666549, 1314.028065048202, -16267.495724986578, 128785.23314488007, -732138.3520168423, 3181671.563784432, -10985493.57770623, 30921344.779352337, -72235042.16555661, 141844255.0106333, -236246855.40332446, 335816039.8627032, -408988435.3879317, 427581834.64527494, -383741632.6710468, 295099008.4598447, -193697579.2392928, 107847858.295481, -50475873.50970038, 19604743.4557604, -6205617.813931994, 1559839.0220559984, -299476.0528275249, 41243.67813321847, -3627.3965424169787, 153.02474117328546 },
        { 29.099132047084716, -751.8581997316893, 9334.790502684873, -74131.11488466612, 422851.4999450316, -1844308.1701815932, 6393225.644768583, -18073339.638897944, 42421535.17409994, -83736127.95380199, 140269796.8352688, -200662664.27936998, 246124883.47940564, -259361601.25966698, 234849228.04504216, -182420113.0028742, 121102649.61343037, -68300071.95656148, 32435158.264193952, -12806588.129354756, 4129178.1592408237, -1059352.0275752412, 207990.87095425374, -29344.171844432447, 2647.822219420157, -114.73500103189745 },
        { -14.922598117971948, 386.4077327284263, -4808.7764878344715, 38285.51363437733, -218987.91340653322, 958011.9447424504, -3331840.1566117, 9452968.18238279, -22276227.625139613, 44165030.89792917, -74345652.91069281, 106939034.44026029, -131978062.90695363, 140050093.61836123, -127827407.69014771, 100202539.5777118, -67228812.90539008, 38386671.13861948, -18495251.22676882, 7428125.895746776, -2443540.098740044, 641759.5943227411, -129450.14978268367, 18829.49019684564, -1757.4022805416046, 78.98336144811006 },
        { 6.789892590567488, -176.12748027873135, 2196.044688034176, -17520.10403484768, 100437.90605235042, -440468.0886237442, 1536022.510651738, -4370903.18710533, 10334108.257761043, -20563660.92663367, 34758338.10270543, -50228260.18057858, 62315245.294273384, -66525277.173631445, 61142444.118908815, -48318760.74965901, 32729806.777525656, -18902817.06669575, 9234364.638114654, -3772113.986145862, 1267206.8485745823, -341624.3560161832, 71166.51139839628, -10762.392774359603, 1051.280828297355, -49.741996154376054 },
        { -2.6877858917124224, 69.81805250526034, -871.8500508382673, 6967.150731972936, -40012.88837593209, 175823.00861407694, -614475.3506701243, 1752766.4768299276, -4155171.9625688703, 8293109.669227406, -14065030.571064996, 20402855.15949336, -25423575.341290724, 27278564.28597539, -25219443.424334787, 20069178.682475608, -13708082.969260758, 7997768.656784679, -3956629.681561111, 1642325.2449592203, -563354.5969060966, 156161.23958350823, -33775.504181255215, 5368.588170275717, -558.6703970746157, 28.51755053807375 },
        { 0.8952680970202711, -23.2810809780877, 291.0684132685697, -2329.0174647092285, 13394.749703418662, -58950.605158159706, 206378.7551746623, -589812.6617094054, 1401213.0421439924, -2803308.185853483, 4767245.964605767, -6936726.824927705, 8674348.639096038, -9345583.269116625, 8681966.252817484, -6948844.623279793, 4779583.1783165755, -2812733.588057378, 1406796.2242838219, -592327.144869506, 207151.66549940134, -59024.787589699314, 13305.296077141329, -2252.900193235736, 256.9407243947181, -14.782823383597018 },
        { -0.2346631625518442, 6.107402967640876, -76.42607872658432, 612.1361608445544, -3524.3539014936086, 15529.22364952267, -54437.401874490504, 155804.7970768242, -370748.86066319194, 743094.3812958933, -1266322.7704379454, 1846988.321440938, -2315996.058516263, 2503208.366917912, -2334266.8878061255, 1876784.462775243, -1298067.9831293845, 769202.0758131563, -388151.07728262554, 165372.74692521789, -58796.27250850937, 17169.463632533578, -4029.192384624871, 736.2369204730579, -96.66448756126715, 6.863722578458062 },
        { 0.03999999670183287, -1.0416665821171263, 13.043477220454752, -104.54544636595686, 602.3809062493557, -2656.4998013221493, 9321.051952503938, -26705.553665618572, 63622.05446354369, -127685.9290564853, 217917.31948348627, -318385.6949256495, 400023.05377209804, -433358.30960703123, 405218.1609787781, -326875.9843421241, 226997.21219653354, -135196.8695626768, 68671.4260957893, -29516.66573219321, 10625.999712703537, -3162.499929870138, 766.6666535857361, -149.99999824798263, 24.99999984987232, -2.8159581715656623 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_26d[27][27] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.854419706132967, 25.99999973932002, -162.49999676264912, 866.6666409746537, -3737.499853728838, 13155.999363683206, -38371.66446817706, 93971.42237791234, -195284.36051749773, 347172.19374624075, -531173.4524395127, 702378.113817631, -804808.2499993008, 800046.0658204048, -689835.6343179598, 515077.27055101015, -331983.3952971518, 183797.03452625702, -86793.04363118573, 34621.047720843104, -11511.498308829645, 3132.3804799636537, -679.5453490259937, 113.04346026341382, -13.541664458480206, 1.0399998256817928, -0.038461531869106225 },
        { 7.0704831104667765, -102.36701673959008, 808.7938452874803, -4614.011570405966, 20545.75802482684, -73689.29154269183, 217587.53390120258, -537521.24839701, 1124289.7546229565, -2008766.7454814746, 3085689.1072288025, -4093531.3624800104, 4703186.483069589, -4686024.229315384, 4048384.2965556392, -3027895.308731263, 1954450.3279252045, -1083454.12598295, 512221.0783254631, -204531.4332434556, 68069.71153661502, -18537.883158839435, 4024.7076140204995, -669.9812605926004, 80.30919811031019, -6.171351721047163, 0.2283535391423412 },
        { -15.510530604159737, 277.5588900617723, -2520.908056996094, 15493.43246863415, -71759.06283273581, 263625.7550048087, -791083.7002042303, 1977002.635584009, -4171246.549256283, 7503402.093724235, -11588734.286673201, 15442235.043733155, -17807864.025502525, 17798561.807195842, -15418026.12609645, 11558439.785829326, -7475978.381289039, 4151785.8286859468, -1965966.7360554698, 786140.2836997433, -261970.91656958582, 71427.46908025576, -15523.849846059598, 2586.710035038352, -310.3383082313273, 23.867372576946043, -0.8838102535815112 },
        { 30.54116799958973, -616.7211039345873, 6135.842436784525, -40125.38526052268, 193488.85495922394, -730128.985871692, 2232581.08698022, -5657402.187324305, 12063958.523655748, -21883888.23575943, 34028932.630706705, -45598799.87445718, 52831694.267755374, -53015488.32641228, 46082989.42007488, -34650605.41517924, 22470907.891989745, -12508265.250753343, 5935234.433985846, -2377761.9207094214, 793685.9937497969, -216730.514718413, 47168.75161660297, -7869.577331245128, 945.2412282981398, -72.77391220636378, 2.6974832058931377 },
        { -54.488450304351986, 1188.1367747698237, -12592.346265684908, 86492.35216464885, -432647.5474415945, 1677329.0075078176, -5233605.722435722, 13469117.540765386, -29074004.56784796, 53259755.40551081, -83487003.60567273, 112626699.77111633, -131235777.97055158, 132335773.4396949, -115517806.09936897, 87181174.21243228, -56721333.64928748, 31664945.69520085, -15064069.22736001, 6048984.449941633, -2023371.4221301626, 553574.5720702969, -120688.7980184942, 20167.72712336866, -2425.9692847635683, 187.02775579987602, -6.941173681229411 },
        { 88.6814568536006, -2037.3636518841336, 22601.584054874344, -161342.3872343172, 832958.1445726254, -3312376.832392302, 10547364.127062175, -27591501.76547375, 60355083.71454808, -111781999.63154744, 176838311.9481002, -240422010.88591897, 282018070.15039253, -286025513.5570815, 250935633.91796303, -190221996.83341658, 124248561.93681145, -69606120.74761419, 33218441.0737189, -13376873.569304785, 4486093.068910566, -1230239.7963673056, 268790.95285559655, -45005.16385773019, 5423.516897749046, -418.8246947205094, 15.568126993223377 },
        { -132.32481182314035, 3155.1006120471675, -36211.04974077973, 266465.67174093676, -1412722.7019257436, 5747714.299362463, -18660724.073497944, 49623131.46791312, -110065101.08393487, 206268084.87626252, -329628206.1290467, 452073176.454003, -534323921.0629319, 545529283.3153032, -481417563.3608874, 366844382.31095743, -240731660.2025971, 135426842.33657736, -64874786.7899003, 26214318.264248356, -8818754.486160025, 2425315.1849951167, -531289.1132679381, 89171.63801685694, -10769.955199230104, 833.4176897530942, -31.038507178432134 },
        { 181.68913792213473, -4452.23454589395, 52437.78003561509, -395290.76491355465, 2142605.6781503665, -8893513.570780084, 29395029.76676938, -79415652.5765322, 178618388.2363267, -338867130.50448644, 547397080.2103015, -757907390.4168665, 903377203.4472982, -929257035.7899204, 825557121.3647358, -632874099.049218, 417563555.40575045, -236061933.9302718, 113588836.9395731, -46085859.98145472, 15561707.428369828, -4294453.9240828855, 943722.3868175229, -158858.4311087711, 19238.67855205982, -1492.5161973021632, 55.71570651080357 },
        { -230.17185763374746, 5757.996553926277, -69191.6207041854, 531749.6654181319, -2935655.2449751273, 12397550.830168966, -41640577.33282979, 114178251.17446755, -260307947.9721677, 499965281.10842806, -816692216.9494267, 1142233230.554946, -1373954020.3159008, 1425047463.6449578, -1275553276.8910537, 984537554.4974841, -653642558.019977, 371634079.56789356, -179759648.71594247, 73283995.81305526, -24855431.399327256, 6887309.906663133, -1519265.3487500898, 256643.6934256369, -31183.24564184657, 2426.5867107715885, -90.84456483736113 },
        { 269.529140369302, -6850.742043375589, 83633.32042760022, -652818.6564312096, 3659321.2880789167, -15683500.283005908, 53430644.1399076, -148503900.19130257, 342929557.8211649, -666624856.0513747, 1101225507.3344557, -1556334769.2151895, 1890237351.765921, -1978119574.6575744, 1785275582.9906232, -1388511585.939971, 928363360.6251606, -531282466.24003124, 258539470.73486555, -105993658.9696023, 36137397.52928152, -10062234.342590837, 2229698.866323824, -378252.8423435541, 46141.80540616329, -3603.990244849351, 135.39520718877577 },
        { -292.0601990236732, 7516.538900086345, -92923.02882058528, 734557.2452142686, -4169843.5477608386, 18097308.503121123, -62423069.114453904, 175619796.83842206, -410378413.41146296, 806931462.4125346, -1347757340.0071068, 1924877176.1646996, -2361304546.0618424, 2494531828.2234077, -2271476109.3639503, 1781515494.6154375, -1200534744.9274607, 692132408.1392703, -339156306.35816467, 139951384.1384135, -48007150.48712094, 13444197.528374458, -2995224.4066278315, 510705.2292142301, -62597.952633434106, 4911.4369760663185, -185.30128364657313 },
        { 292.9887987699939, -7615.377526899416, 95102.394904596, -759587.4096069782, 4357448.2274088, -19113798.06406197, 66640683.43880927, -189516688.9251824, 447642558.93871534, -889656819.316014, 1501671082.081764, -2166977599.8679967, 2685207398.625766, -2864536647.883994, 2633066369.8405633, -2083862904.2593803, 1416482938.8707836, -823401534.4286518, 406666075.71724963, -169068949.0600444, 58408945.17664303, -16467951.866023207, 3692469.216051634, -633431.4463982756, 78090.4272852555, -6160.680355172368, 233.64816360442248 },
        { -272.0610255309043, 7127.704878116968, -89745.44157799015, 722902.8884074183, -4183419.8185459413, 18516294.689336877, -65156530.754804015, 187055642.8993373, -446107767.5616671, 895323023.3874576, -1526247674.59452, 2224432830.748089, -2783906934.874972, 2999269049.713027, -2783906946.0553627, 2224432848.583908, -1526247692.8994322, 895323037.6423546, -446107776.38812065, 187055647.30670765, -65156532.5283346, 18516295.25836958, -4183419.9610272674, 722902.9152639577, -89745.44516772026, 7127.705181671038, -272.0610377727586 },
        { 233.64815436441177, -6160.680129134086, 78090.42465593519, -633431.4271510338, 3692469.116811252, -16467951.484875288, 58408944.051582836, -169068946.47705153, 406666071.1540435, -823401528.5514586, 1416482934.5501776, -2083862906.388428, 2633066383.1261845, -2864536673.7023535, 2685207433.2884154, -2166977636.098508, 1501671112.7601142, -889656840.6941308, 447642571.2514974, -189516694.76920947, 66640685.70473083, -19113798.770943094, 4357448.400609833, -759587.4417131888, 95102.39913974138, -7615.377881339589, 292.98881294183 },
        { -185.30127768147972, 4911.43683352257, -62597.9510232969, 510705.2179040277, -2995224.351591159, 13444197.334849076, -48007149.99280652, 139951383.27767694, -339156305.6888953, 692132409.6377289, -1200534752.4297352, 1781515512.886946, -2271476141.4784026, 2494531872.862343, -2361304596.8455496, 1924877224.2155976, -1347757378.0742362, 806931487.7132655, -410378427.4795781, 175619803.33738747, -62423071.58144887, 18097309.259874303, -4169843.730690185, 734557.2787609026, -92923.03320754417, 7516.539264689735, -292.060213518155 },
        { 135.39520404460103, -3603.9901732410613, 46141.80464790166, -378252.8375391083, 2229698.84667667, -10062234.294992482, 36137397.50903944, -105993659.35062508, 258539472.7375699, -531282472.5031141, 928363375.2218391, -1388511613.0459628, 1785275624.2555697, -1978119627.1100442, 1890237407.9041224, -1556334820.0410306, 1101225546.279206, -666624881.2756264, 342929571.56279904, -148503906.43544012, 53430646.47846429, -15683500.992506612, 3659321.458039397, -652818.6873713284, 83633.32444952545, -6850.742376022619, 269.5291535405898 },
        { -90.84456365408677, 2426.586687472219, -31183.2454496434, 256643.69281114262, -1519265.3510152171, 6887309.944823276, -24855431.639472317, 73283996.81616145, -179759651.89598554, 371634087.5606317, -653642574.4721284, 984537582.6973445, -1275553317.4828763, 1425047513.1734095, -1373954071.6895537, 1142233275.943095, -816692251.0479522, 499965302.8438671, -260307959.65890113, 114178256.42717735, -41640579.282199666, 12397551.417119319, -2935655.384689099, 531749.690719917, -69191.62397912527, 5757.996823851524, -230.1718682912963 },
        { 55.715706396737524, -1492.5161993182699, 19238.678642060746, -158858.43244130397, 943722.3983039599, -4294453.993125414, 15561707.740446888, -46085861.07999139, 113588840.07402363, -236061941.26749653, 417563569.76225525, -632874122.7455348, 825557154.4843469, -929257075.2834479, 903377243.6514169, -757907425.3994719, 547397106.1562529, -338867146.8681674, 178618396.95653844, -79415656.46625729, 29395031.20102328, -8893514.000293056, 2142605.7799216495, -395290.78327442333, 52437.78240474256, -4452.234740668176, 181.68914559692493 },
        { -31.03850746524373, 833.4177002019858, -10769.955367957846, 89171.63973285731, -531289.1254114378, 2425315.2493387903, -8818754.753343632, 26214319.14890488, -64874789.202910654, 135426847.79141104, -240731670.59169698, 366844399.09466267, -481417586.402992, 545529310.4010291, -534323948.3005954, 452073199.9142602, -329628223.3754978, 206268095.67280406, -110065106.80115119, 49623134.004250295, -18660725.004338387, 5747714.57701439, -1412722.7674929863, 266465.6835371733, -36211.05125935517, 3155.1007366639496, -132.32481672640236 },
        { 15.568127310452033, -418.82470457024766, 5423.517040874911, -45005.16519818807, 268790.9617759005, -1230239.8413527615, 4486093.24874035, -13376874.14641909, 33218442.609904375, -69606124.15016979, 124248568.31209953, -190222006.9947737, 250935647.7043073, -286025529.60975206, 282018086.1575723, -240422024.57582667, 176838321.94814774, -111782005.85836704, 60355086.99680768, -27591503.215772267, 10547364.657477975, -3312376.990138958, 832958.1817312526, -161342.3939057068, 22601.584912235663, -2037.3637221454042, 88.68145961533743 },
        { -6.941173895977214, 187.0277621379369, -2425.9693732501373, 20167.727923211885, -120688.80318824336, 553574.5974728748, -2023371.521574466, 6048984.763159566, -15064070.04879145, 31664947.49088262, -56721336.97814574, 87181179.47073248, -115517813.17500252, 132335781.62511477, -131235786.08391345, 112626706.67491604, -83487008.62509446, 53259758.5187963, -29074006.203373164, 13469118.261295808, -5233605.985270891, 1677329.085502781, -432647.56577974453, 86492.35545197401, -12592.346687609166, 1188.1368093126325, -54.488451661154876 },
        { 2.6974833152985815, -72.77391535766951, 945.2412714024836, -7869.5777134680875, 47168.75404687683, -216730.52647468622, 793686.0391894988, -2377762.0620864523, 5935234.80119437, -12508266.046354357, 22470909.356234908, -34650607.713850886, 46082992.49496905, -53015491.867512286, 52831697.76243833, -45598802.83727626, 34028934.77731467, -21883889.563352607, 12063959.219345555, -5657402.493133937, 2232581.1983168167, -730129.0188554253, 193488.8627035868, -40125.386647204825, 6135.842614594018, -616.7211184813929, 30.541168570697362 },
        { -0.8838102968307967, 23.867373805566324, -310.3383248372688, 2586.7101805976467, -15523.850762302016, 71427.47346804135, -261970.9333907986, 786140.3355984443, -1965966.8699866484, 4151786.1170643936, -7475978.909365245, 11558440.611264536, -15418027.22554739, 17798563.069332633, -17807865.267158393, 15442236.093635911, -11588735.045366298, 7503402.561952749, -4171246.7941664197, 1977002.7430653474, -791083.7392786645, 263625.76656638423, -71759.06554454299, 15493.432953796259, -2520.908119163011, 277.5588951451229, -15.510530803668553 },
        { 0.22835355189018666, -6.17135208012747, 80.30920292799446, -669.9813025150562, 4024.707876225106, -18537.88440617478, 68069.71629295878, -204531.44783342458, 512221.1158130421, -1083454.2063519456, 1954450.4745845888, -3027895.537288088, 4048384.6000533206, -4686024.576957983, 4703186.824296713, -4093531.6504681082, 3085689.314943019, -2008766.873477114, 1124289.8214828025, -537521.2777045278, 217587.54454468092, -73689.29468910852, 20545.75876228724, -4614.011702264135, 808.7938621747245, -102.3670181199561, 7.070483164631607 },
        { -0.038461534215968644, 1.0399998914436377, -13.5416653367978, 113.04346787154823, -679.5453964206461, 3132.3807044595146, -11511.499161964222, 34621.05032773145, -86793.0503103571, 183797.0488043133, -331983.4212918552, 515077.31098097237, -689835.6878924582, 800046.1270983702, -804808.3100537615, 702378.1644378699, -531173.4889019895, 347172.2161914013, -195284.37223127935, 93971.42750841504, -38371.66633005888, 13155.999913749347, -3737.499982589355, 866.6666640056105, -162.4999997112273, 25.99999998027982, -2.854419715586908 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_27d[28][28] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.891456764639534, 27.000000320317124, -175.50000433587232, 975.0000375000053, -4387.500233077219, 16146.001108693006, -49335.004187661725, 126861.44148277467, -277509.4080961602, 520758.40468767134, -843628.6309410847, 1185263.387455562, -1448655.277748407, 1542946.477827161, -1432736.040531151, 1158924.284307613, -814868.6511606994, 496252.19715181657, -260379.24307709993, 116846.088671514, -44401.51431002391, 14095.71900572841, -3669.5467222903276, 763.0437489250153, -121.8750443353498, 14.04000520613231, -1.0384619269094932, 0.03703705095926512 },
        { 7.272519374358961, -108.14399985545835, 885.186012566743, -5255.200150093397, 24407.776060001615, -91497.31739901454, 282990.64127214445, -733963.6005400895, 1615837.648400428, -3047211.0974861505, 4955950.419279094, -6985284.771833392, 8560363.956664406, -9138089.759439534, 8501719.114015423, -6888408.134869889, 4850463.797802508, -2957704.972986398, 1553649.5412873826, -697915.213116165, 265450.46489880315, -84339.69399401019, 21972.698020605687, -4572.124050813565, 730.7283799701064, -84.22850995720266, 6.233237557269391, -0.22241983325934186 },
        { -16.23370951304488, 298.7907228716491, -2807.5210497073576, 17928.89743814675, -86541.1391300795, 332137.03917158226, -1043622.7963729838, 2737586.754975987, -6078430.1078165285, 11539280.205332939, -18867376.069645707, 26709067.250867143, -32850555.616342306, 35175467.8370087, -32812171.34731651, 26646402.382184133, -18800556.26870647, 11484392.76463862, -6042087.3784657605, 2717976.9232799467, -1035082.2969838092, 329245.25140225777, -85866.13628215116, 17884.15296556696, -2860.7761655985873, 330.0155213166292, -24.440470558413384, 0.8727026391393837 },
        { 32.59061888492419, -677.6359300734892, 6971.5702154669125, -47320.20660955704, 237579.0605978414, -935925.5492341787, 2995225.598057078, -7963830.283425599, 17866486.69823986, -34195856.07628635, 56282742.647564426, -80110570.82425524, 98982853.63507566, -106401305.43759897, 99585717.73726848, -81108526.02779558, 57373303.09813882, -35126141.60885364, 18517636.86506937, -8345069.189614258, 3183225.9160282654, -1014037.7668095685, 264814.0885730407, -55223.25496855636, 8843.578570700227, -1021.2459131746452, 75.70472993446603, -2.705619193740337 },
        { -59.39701432759496, 1334.7885357601494, -14627.39644456523, 104214.43945126957, -542323.2152119684, 2193380.0217337385, -7158453.231005984, 19321197.10215791, -43860996.32589481, 84749549.76544301, -140579906.12037215, 201400899.76276505, -250219752.25705883, 270244485.4998471, -253969323.81176797, 207587993.2538805, -147303657.86565644, 90437617.56552047, -47795876.87063005, 21587959.759977065, -8251486.111289045, 2633425.231480314, -688874.0064955862, 143876.90590351776, -23073.49842520551, 2667.990480122572, -198.01726026427073, 7.08491950681196 },
        { 98.94258458138505, -2344.3423683518645, 26893.71915365809, -199066.62113950585, 1068534.7300881273, -4429849.853232127, 14744977.063228523, -40430926.71292206, 92966549.20570022, -181541247.16956443, 303806653.64146376, -438513566.1430319, 548307767.8145373, -595478344.7715185, 562330321.3013374, -461596061.43318534, 328786185.05306673, -202541084.04405883, 107366532.32452407, -48626907.92542707, 18632603.424580082, -5959955.325557044, 1562280.1755345138, -326914.3410844052, 52518.86538215467, -6082.578539618376, 452.1232843633061, -16.199190813614173 },
        { -151.4036502892075, 3725.4144668917056, -44222.65284887811, 337376.88776924124, -1858970.6003022387, 7880630.515009072, -26729521.804043252, 74462344.37174352, -173518961.07866687, 342699136.2433327, -579080054.8625846, 842844542.1338857, -1061541668.806543, 1160206508.749721, -1101772790.9259105, 908910350.0523151, -650280026.4485145, 402190314.490675, -213968922.90864372, 97224650.80379623, -37364999.04055977, 11984386.196340933, -3149315.1443042485, 660526.0803178616, -106339.39252948802, 12340.186525592713, -918.9364349519282, 32.9808711392989 },
        { 213.62671422956498, -5404.99445226131, 65857.22095538747, -514674.451536033, 2898629.9240743937, -12531375.912400136, 43249265.47414265, -122338856.04266264, 288929101.5962086, -577363682.9722755, 985692828.1928672, -1447712251.9811966, 1838011401.1023324, -2023182094.6261864, 1933521826.4245436, -1604174546.4058235, 1153613064.453154, -716818386.64818, 382967757.63108903, -174687290.0269177, 67372448.60192162, -21679101.581143655, 5713991.967751805, -1201748.4152470327, 193968.13731029766, -22562.758415124063, 1683.9131376322166, -60.56147613704156 },
        { -278.70493674995726, 7201.904464559782, -89552.3423539552, 713523.7054650732, -4092458.0622671843, 17995646.013898384, -63089046.355910644, 181036043.99666572, -433158519.0005065, 875826010.9786025, -1511197361.6829975, 2240877949.5744348, -2869680755.884747, 3183528232.396821, -3064023965.8563924, 2558483964.292106, -1850678943.6497054, 1156114178.0174282, -620698243.9076722, 284403046.2397754, -110142973.3900163, 35577928.134552956, -9410693.484731624, 1985767.582868627, -321498.7358125118, 37504.711515063624, -2806.578913399562, 101.19162506729997 },
        { 336.86933780095075, -8847.991546169536, 111799.49414146048, -904843.3539162064, 5269139.475083757, -23510195.181979142, 83575487.98207411, -242994835.23883098, 588619988.2545811, -1203928969.717307, 2099609835.3634038, -3144270611.616416, 4063376406.352281, -4545726516.630819, 4409011332.205308, -3707864360.878849, 2699761854.237739, -1696803739.7845995, 916118400.2277021, -421956636.14741457, 164207104.24203417, -53280898.50914379, 14152590.634090807, -2998098.7961024344, 487181.26342429925, -57028.39540250475, 4281.396593537641, -154.83610648310713 },
        { -377.72002691306136, 10048.803612065305, -128610.51754138364, 1054277.9997644832, -6217480.439206308, 28089238.177734703, -101077663.21406181, 297384161.3621465, -728657146.4500028, 1506796408.3930821, -2655441082.225794, 4016323098.562386, -5239223709.311488, 5913100199.686576, -5782976562.574685, 4901257593.417302, -3594753346.5552015, 2274753130.186736, -1236019918.904318, 572714497.9440286, -224128353.01489556, 73107347.72109097, -19515136.161294203, 4153362.7397247236, -677867.3565240745, 79677.64436863143, -6005.113778025614, 217.97431149000545 },
        { 393.16207347472766, -10566.755874529808, 136646.17966310392, -1131941.9589457999, 6746360.685194984, -30803536.897738494, 112026206.98992705, -333089849.33059585, 824701775.8554322, -1722997914.6116042, 3067084559.618393, -4684434611.821061, 6168745387.771682, -7025769260.781126, 6931323701.165384, -5923659677.210075, 4379246589.81372, -2792180781.6921954, 1528088887.2836645, -712878553.527591, 280785898.0321638, -92149882.97542448, 24741291.14759462, -5294648.01379088, 868651.2713230539, -102608.93502361678, 7769.792822278021, -283.2900517436286 },
        { -379.94457222425734, 10295.567255255204, -134265.09514884872, 1121861.9667330289, -6745604.151829592, 31078930.014311098, -114068820.67730722, 342330333.5112998, -855573147.7715684, 1804443320.37211, -3242538444.3039756, 4999186458.812223, -6644808588.55058, 7637709470.959134, -7603093597.616018, 6555022264.441834, -4887483044.707881, 3142050894.1170554, -1733314734.6872783, 814844761.5607954, -323321779.65382844, 106862410.4783881, -28886508.862520333, 6221960.946080773, -1027145.286534683, 122053.68491917712, -9294.845945692981, 340.7404849929117 },
        { 340.7404848147714, -9294.845915424195, 122053.68434124709, -1027145.2810758734, 6221960.913007207, -28886508.721130732, 106862410.02865061, -323321778.5900776, 814844759.7434877, -1733314732.8280888, 3142050894.6657586, -4887483051.878837, 6555022282.732256, -7603093629.029082, 7637709512.713677, -6644808633.70586, 4999186499.293217, -3242538474.6632476, 1804443339.4402616, -855573157.7709097, 342330337.86072683, -114068822.22634965, 31078930.457085732, -6745604.250719911, 1121861.9832202476, -134265.09705627925, 10295.56738837518, -379.9445762240742 },
        { -283.2900550330195, 7769.792887560206, -102608.9356961592, 868651.2762980185, -5294648.043045104, 24741291.290895592, -92149883.55874029, 280785900.0344961, -712878559.2801853, 1528088901.1848595, -2792180810.236881, 4379246639.643156, -5923659751.59096, 6931323796.438632, -7025769365.552804, 6168745486.854004, -4684434692.27313, 3067084615.576037, -1722997947.7602084, 824701792.4724735, -333089856.3112433, 112026209.41202338, -30803537.57840794, 6746360.835881901, -1131941.9841217385, 136646.18262521288, -10566.756090441144, 393.1620806325884 },
        { 217.97431705871983, -6005.113908579557, 79677.64591183975, -677867.3688279969, 4153362.81282467, -19515136.5040408, 73107349.0223222, -224128357.12440717, 572714508.8275524, -1236019943.3133407, 2274753177.0482044, -3594753423.729868, 4901257702.951635, -5782976696.922763, 5913100342.0369005, -5239223839.70477, 4016323201.5858235, -2655441152.240451, 1506796449.0617473, -728657166.5062135, 297384169.67699, -101077666.06945238, 28089238.974600095, -6217480.614985004, 1054278.0291608134, -128610.521024764, 10048.803870430129, -377.72003579092177 },
        { -154.8361128081013, 4281.3967491749945, -57028.3973026692, 487181.2788165126, -2998098.8877639924, 14152591.060102513, -53280900.10228064, 164207109.1759613, -421956648.9401038, 916118428.3076993, -1696803792.5485904, 2699761939.4139843, -3707864479.5251613, 4409011475.260344, -4545726665.85354, 4063376541.1381383, -3144270716.7779484, 2099609906.0462356, -1203929010.3802886, 588620008.1413871, -242994843.42767465, 83575490.7790143, -23510195.959627017, 5269139.6463039685, -904843.3825663899, 111799.49754966074, -8847.991801312015, 336.8693467302112 },
        { 101.19163083579436, -2806.579058659518, 37504.7133136832, -321498.75048479624, 1985767.6703590096, -9410693.889801262, 35577929.63942974, -110142978.01099361, 284403058.1077122, -620698269.7012997, 1156114225.973783, -1850679020.3092332, 2558484070.0522346, -3064024092.238632, 3183528363.111105, -2869680873.0475974, 2240878040.3362937, -1511197422.3018122, 875826045.6577936, -433158535.8760444, 181036050.91761422, -63089048.71208543, 17995646.6674966, -4092458.206018123, 713523.7295277737, -89552.34522330851, 7201.904680589797, -278.70494439345913 },
        { -60.56148058633791, 1683.913251191475, -22562.75983201748, 193968.14891567233, -1201748.4845266396, 5713992.287776436, -21679102.76563171, 67372452.22208437, -174687299.27611434, 382967777.6250544, -716818423.5812054, 1153613123.1609716, -1604174626.93384, 1933521922.1409202, -2023182193.1010394, 1838011488.951312, -1447712319.7271152, 985692873.2568618, -577363708.6618105, 288929114.05572414, -122338861.13927203, 43249267.205518216, -12531376.391937837, 2898630.0294724475, -514674.46918319486, 65857.22306302645, -5404.994611548904, 213.6267199055426 },
        { 32.98087409738256, -918.9365111108606, 12340.187480274571, -106339.40037040574, 660526.1271769232, -3149315.3604010446, 11984386.994190011, -37365001.471936315, 97224656.9961852, -213968936.25286716, 402190339.0276204, -650280065.3167701, 908910403.1657097, -1101772853.8390098, 1160206573.244626, -1061541726.1639048, 842844586.2295228, -579080084.113453, 342699152.87907416, -173518969.12808317, 74462347.65858659, -26729522.918958906, 7880630.82346084, -1858970.66806946, 337376.89911756455, -44222.654205659346, 3725.4145697098943, -151.40365397076508 },
        { -16.199192517318963, 452.1233284883148, -6082.579094432163, 52518.86994814383, -326914.36840302433, 1562280.301343986, -5959955.789214051, 18632604.834765334, -48626911.50982934, 107366540.03464262, -202541098.1706014, 328786207.3808301, -461596091.8641178, 562330357.2626472, -595478381.5426092, 548307800.4472692, -438513591.17554826, 303806670.21372986, -181541256.57943195, 92966553.75084957, -40430928.56655958, 14744977.691319944, -4429850.026850264, 1068534.7682233688, -199066.6275262167, 26893.719917778377, -2344.342426373182, 98.94258666602104 },
        { 7.0849203532779645, -198.01728227883467, 2667.9907575077905, -23073.50071166756, 143876.91959946198, -688874.069492315, 2633425.4633173356, -8251486.815423997, 21587961.547471978, -47795880.711694136, 90437624.58231515, -147303668.94007877, 207588008.31901312, -253969341.5857819, 270244503.63951564, -250219768.33162898, 201400912.0736822, -140579914.25847572, 84749554.38113339, -43860998.552404046, 19321198.009380985, -7158453.538170917, 2193380.1065823026, -542323.2338469465, 104214.4425722692, -14627.39681814262, 1334.7885641693722, -59.39701535080669 },
        { -2.7056195515322883, 75.7047392673193, -1021.2460309442182, 8843.579542724618, -55223.26079754544, 264814.1153554588, -1014037.8652591675, 3183226.2147301426, -8345069.9472869, 18517638.49238801, -35126144.574141644, 57373307.77378334, -81108532.37956856, 99585725.22254463, -106401313.06584714, 98982860.38793989, -80110575.9898451, 56282746.05841792, -34195858.009302944, 17866487.629732374, -7963830.662728408, 2995225.7264062488, -935925.5846681132, 237579.06837988703, -47320.20791288758, 6971.570371519752, -677.6359419543177, 32.5906193135963 },
        { 0.8727027641038434, -24.440473824884396, 330.01556257954553, -2860.776506526857, 17884.155012127398, -85866.14567666753, 329245.28590342926, -1035082.4015803225, 2717977.188467658, -6042087.947924665, 11484393.80010939, -18800557.900439143, 26646404.596624713, -32812173.954810586, 35175470.49139547, -32850557.964427967, 26709069.04544291, -18867377.25359096, 11539280.875938281, -6078430.4307186715, 2737586.8863985036, -1043622.8408252391, 332137.0514379774, -86541.14182411922, 17928.897889326407, -2807.5211037389327, 298.79072698880384, -16.2337096617883 },
        { -0.222419867092841, 6.23323844294026, -84.22852115367571, 730.728472556578, -4572.124607085242, 21972.70057214586, -84339.70335765238, 265450.4932695762, -697915.2850261807, 1553649.6957020308, -2957705.2532857703, 4850464.23933761, -6888408.733646105, 8501719.818671187, -9138090.476182392, 8560364.5903825, -6985285.2558558965, 4955950.738400622, -3047211.278174047, 1615837.7353524077, -733963.6359176255, 282990.6532346144, -91497.3206987691, 24407.776784757516, -5255.200271465087, 885.1860271033818, -108.14400096383963, 7.272519414439468 },
        { 0.03703705684139073, -1.0384620810376628, 14.040007155585506, -121.87506046576993, 763.0438459030889, -3669.547166858306, 14095.720636338103, -44401.519248499004, 116846.10118699558, -260379.2699531639, 496252.24587642244, -814868.7278946115, 1158924.3883165366, -1432736.1628851218, 1542946.6022085305, -1448655.387685433, 1185263.4713864839, -843628.686252588, 520758.43599756376, -277509.4231571674, 126861.44760907162, -49335.00625876875, 16146.001679833711, -4387.500358528971, 975.0000585079621, -175.50000685214823, 27.000000512261312, -2.891456771584899 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_28d[29][29] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.9271710204424193, 27.999999492964978, -188.9999932873079, 1091.9999427183423, -5118.749646498605, 19655.998319795483, -62789.99359984496, 169148.5513761665, -388513.07238624047, 767433.2162492884, -1312310.7768791858, 1952197.8149838846, -2535145.7271422376, 2880165.506511369, -2865470.7301125554, 2496143.3442170257, -1901359.151091141, 1263186.6785938065, -729061.4333902096, 363520.92985282274, -155405.19444496633, 56382.835997562375, -17124.538733742014, 4273.0417311257015, -853.1246410130652, 131.03994280872234, -14.538455072253162, 1.03703656263359, -0.035714269244623495 },
        { 7.470066249910078, -113.99274469667479, 965.4510069061774, -5955.64274333652, 28801.797069375487, -112637.29879960313, 364154.62419195, -989340.966117146, 2286781.866969989, -4539207.037724068, 7792286.454104197, -11628640.001740817, 15140914.780470043, -17239805.13507836, 17184501.562044892, -14994263.237340368, 11437842.73124733, -7608475.61471003, 4396253.054039502, -2194242.083974304, 938886.6883227224, -340917.58917937626, 103620.02815701248, -25873.551886005236, 5168.93195717892, -794.4009142301119, 88.1825858752243, -6.293179735513605, 0.2168273848847713 },
        { -16.95222960250814, 320.6224309067569, -3113.160714967901, 20627.812877354518, -103596.50695596306, 414594.6366376785, -1361312.0762397577, 3739777.167512869, -8716749.329433674, 17415575.307855133, -30052989.604694616, 45040821.42052225, -58853988.693807006, 67214848.12273042, -67172616.77447969, 58742648.12828057, -44897703.480060555, 29917770.139482215, -17313401.675680354, 8653307.920399012, -3707225.144564717, 1347634.5653252765, -410023.8856370172, 102476.84608170328, -20489.95927366642, 3151.5265315745505, -350.08927090712547, 25.001009409635596, -0.8619303414149742 },
        { 34.66370933365778, -741.3987459703541, 7878.417111890345, -55429.26521214943, 289295.85866585147, -1187652.5856702705, 3970011.77113196, -11051061.068534525, 26019310.02622251, -52400880.80919735, 91009479.85067867, -137124228.73718235, 179978634.36224753, -206328125.86363444, 206873393.14205608, -181426430.82630005, 139012879.2850363, -92836594.23987423, 53830323.66482935, -26952127.458966766, 11565139.045274103, -4210176.501041777, 1282648.1118279085, -320955.9769309246, 64244.997419401945, -9891.449033300321, 1099.8285896779767, -78.6106156858696, 2.712355583228995 },
        { -64.46132321052909, 1491.3711611840295, -16879.358744444053, 124576.45563581433, -673416.812898668, 2836373.5655998224, -9663801.16189734, 27295765.385759182, -65007552.1553778, 132132130.9754859, -231227213.9712486, 350594266.3155315, -462625017.21618086, 532785692.5639402, -536313820.3381449, 471975059.11533636, -362743523.0313556, 242907898.09706253, -141189490.14873108, 70845992.59353893, -30459942.590744507, 11108516.858280238, -3389789.286538852, 849494.2719262936, -170275.3227061194, 26249.64299701004, -2922.1225818401285, 209.08739632379644, -7.221603179350748 },
        { 109.76019659958398, -2679.301398537337, 31747.212942062084, -243347.5328902818, 1356108.9863528837, -5851337.941816333, 20320903.02317188, -58281343.25139667, 140534349.76930326, -288575929.2272936, 509322570.88762367, -777842019.8960608, 1032755103.6478034, -1195749734.911881, 1209293055.4765472, -1068596565.7572854, 824279497.5473799, -553766501.9798946, 322814837.402984, -162408660.74734405, 69993789.07634647, -25581785.06336025, 7821883.296229588, -1963777.4962719486, 394288.7207733173, -60878.161876093625, 6786.764011503673, -486.2663847394744, 16.815990923816454 },
        { -171.99338516641674, 4362.544879182192, -53498.19307005251, 422587.30920871504, -2416503.5699169086, 10656654.183381103, -37692328.89263682, 109772020.45938042, -268124106.51167247, 556603607.6113347, -991558030.0371441, 1526490650.7570233, -2040888247.3947513, 2377410047.5660043, -2417264535.908012, 2146214192.2812252, -1662566905.9925425, 1121213569.08808, -655859438.5786983, 330996040.56942236, -143056789.9692853, 52421506.28450841, -16066705.58461098, 4042617.814177646, -813330.3345630128, 125814.7600189548, -14050.517383343931, 1008.3499697482913, -34.92368652010542 },
        { 248.975635476855, -6496.800313938682, 81795.22491355966, -661831.8741396614, 3867401.7033937518, -17386301.38717881, 62544679.972554184, -184865549.62139392, 457408312.4310419, -960291184.7825061, 1727634873.587524, -2682781621.7363524, 3614327140.1667175, -4238925394.0668573, 4336119162.761587, -3870823876.390733, 3013207277.5901957, -2041059996.5227687, 1198727163.7657447, -607185539.790461, 263306664.78779894, -96783043.58472067, 29747347.604814313, -7504514.304179526, 1513499.3160899067, -234653.868163031, 26260.45979566397, -1888.3163423862802, 65.5212684461359 },
        { -333.9043497362271, 8902.479620766104, -114408.50224207476, 943835.9450718208, -5616009.657268255, 25673053.48239988, -93779337.06839268, 281066273.72244227, -704217362.738387, 1495232906.1279552, -2717457003.191975, 4258473906.454473, -5784392299.990974, 6834367369.240922, -7037995409.146789, 6321013298.838796, -4947783673.338907, 3368425893.9826565, -1987452004.172362, 1010972716.75136, -440125413.19678885, 162360768.35251376, -50070467.63082425, 12670794.089949345, -2562819.310222389, 398413.24615256337, -44699.477350033776, 3221.808772604431, -112.03900396793908 },
        { 415.7349689802228, -11270.557191422839, 147216.4554515489, -1233768.2316113925, 7453042.950389772, -34565377.03409909, 127992799.7142403, -388539746.2196824, 985152940.6540474, -2114935713.5636268, 3883049574.4563565, -6142341797.56152, 8415459211.38643, -10021993960.668793, 10395902954.028454, -9399494050.164164, 7402938477.42951, -5068616143.702812, 3006363651.3609424, -1536733082.6171632, 672043811.1014587, -248958479.30402485, 77077510.31526352, -19576594.29576841, 3973158.826210407, -619644.867964419, 69729.63224644409, -5040.139134767029, 175.7390885807348 },
        { -481.24935868444123, 13219.048310795253, -174933.92476818844, 1485067.3966187981, -9085361.663892964, 42659517.185221575, -159869725.8142492, 490947116.35354686, -1258665952.947311, 2730752221.4595594, -5064014861.086126, 8086225655.288789, -11177195150.952505, 13421808656.02717, -14031013593.888563, 12778535131.211725, -10132662993.552912, 6981659745.319068, -4165636913.105473, 2141130891.7431736, -941226789.6180499, 350376179.2207279, -108972387.25733604, 27796334.01922815, -5664189.697598997, 886736.7722439949, -100144.15934369834, 7263.078454095173, -254.06020854656745 },
        { 518.4026279190084, -14389.547154711521, 192445.10769296967, -1651142.549471518, 10209101.221462838, -48445032.7502983, 183462428.8885412, -569246502.8182853, 1474265160.8594391, -3230279001.183601, 6048098486.283346, -9747486868.976114, 13593967827.050613, -16463634392.839285, 17351406566.586388, -15925243847.338095, 12720909107.94047, -8826265836.493834, 5301069903.300989, -2741801769.4281445, 1212417862.8552294, -453858230.8742226, 141905766.1218735, -36378702.08245038, 7448337.004901259, -1171307.9795928884, 132848.52833500272, -9674.15325308767, 339.7053793208385 },
        { -519.8346986142286, 14551.783076681812, -196300.24533220328, 1699065.4263394782, -10599427.203131035, 50752864.71857288, -193958735.74591795, 607342320.225906, -1587390411.4321237, 3510021612.7079744, -6631604931.979743, 10783818281.291246, -15171852584.814814, 18533040800.113956, -19696375418.678333, 18224645402.00244, -14672183766.401339, 10257317849.780418, -6205460523.272543, 3232010339.8703957, -1438760678.854355, 542040235.5184392, -170516015.89462858, 43969230.07872896, -9052836.022033814, 1431238.4934623204, -163158.6188266253, 11939.340430127864, -421.2020949190323 },
        { 485.1790387617729, -13675.443816055462, 185791.23897503637, -1619881.412235286, 10181495.407169422, -49128058.741888575, 189233097.98191574, -597327113.2964216, 1574045034.7875078, -3509549468.4187317, 6686666059.806916, -10965797180.680761, 15559467502.1204, -19168435610.756542, 20544183012.98794, -19168435495.544697, 15559467317.436049, -10965796989.382484, 6686665908.966465, -3509549373.3654237, 1574044986.2176554, -597327093.1663387, 189233091.2702664, -49128056.97307713, 10181495.049421275, -1619881.3591936138, 185791.2336527521, -13675.443506889025, 485.17903208738284 },
        { -421.2021008150071, 11939.340707070858, -163158.62360071493, 1431238.5410034407, -9052836.341716638, 43969231.65223552, -170516021.82466644, 542040253.137337, -1438760720.813808, 3232010420.3855276, -6205460647.147843, 10257317998.582462, -14672183893.738745, 18224645450.67202, -19696375352.29411, 18533040627.826557, -15171852357.979254, 10783818063.232424, -6631604766.599966, 3510021510.94658, -1587390360.251217, 607342299.2438315, -193958728.8058274, 50752862.900285766, -10599426.836877767, 1699065.372185341, -196300.23990393378, 14551.782761080076, -519.8346917287765 },
        { 339.705384020123, -9674.153478727174, 132848.53223617157, -1171308.018450138, 7448337.265379388, -36378703.35843914, 141905770.89262033, -453858244.8884317, 1212417895.6974995, -2741801830.8605337, 5301069993.887343, -8826265936.683908, 12720909175.708378, -15925243835.028204, 17351406448.770737, -16463634185.760529, 13593967582.674532, -9747486645.830717, 6048098321.978551, -3230278901.9954247, 1474265111.621604, -569246482.8192365, 183462422.31858817, -48445031.03764703, 10209100.877712788, -1651142.4987585198, 192445.1026131375, -14389.546858962642, 518.4026213981643 },
        { -254.0602118824504, 7263.078620222822, -100144.16223223112, 886736.8010783037, -5664189.890283446, 27796334.958522208, -108972390.73619011, 350376189.2965491, -941226812.7490083, 2141130933.527021, -4165636970.9750934, 6981659800.74288, -10132663011.571236, 12778535075.546787, -14031013449.431372, 13421808442.69137, -11177194916.343544, 8086225449.021063, -5064014712.715969, 2730752133.2868557, -1258665909.6570654, 490947098.90928113, -159869720.1168466, 42659515.70631392, -9085361.36792518, 1485067.3530231183, -174933.92040086086, 13219.048055870464, -481.2493529909805 },
        { 175.73909065242708, -5040.1392444479, 69729.63417181573, -619644.8872897675, 3973158.9549248912, -19576594.920251746, 77077512.60144803, -248958485.80599654, 672043825.6204962, -1536733107.5397177, 3006363682.5066195, -5068616165.274515, 7402938462.782369, -9399493974.113321, 10395902809.516045, -10021993767.600546, 8415459009.299068, -6142341624.970564, 3883049452.6312733, -2114935642.1095037, 985152905.8978951, -388539732.3087198, 127992795.19308458, -34565375.8645776, 7453042.716861647, -1233768.197239813, 147216.45200442427, -11270.556989373312, 415.73496439443363 },
        { -112.03900506201815, 3221.808836938941, -44699.478496282056, 398413.2577810325, -2562819.3873668513, 12670794.4626637, -50070468.97520744, 162360772.08356652, -440125421.20742285, 1010972729.4236544, -1987452017.1260676, 3368425895.08545, -4947783644.052992, 6321013223.250851, -7037995285.34811, 6834367214.252064, -5784392143.546059, 4258473775.8521204, -2717456912.4142284, 1495232853.4670331, -704217337.3248962, 281066263.608605, -93779333.79464951, 25673052.63786668, -5616009.488896238, 943835.9202904392, -114408.49975141279, 8902.479473947375, -333.9043463399174 },
        { 65.52126891069449, -1888.316375514986, 26260.460399153453, -234653.87440101543, 1513499.3572443782, -7504514.5024306495, 29747348.305933844, -96783045.46465063, 263306668.5901591, -607185544.9698377, 1198727166.6846104, -2041059988.7987158, 3013207247.510923, -3870823814.823672, 4336119070.332311, -4238925283.4418225, 3614327031.526554, -2682781532.664047, 1727634812.451184, -960291149.6423354, 457408295.5850687, -184865542.94878078, 62544677.81977901, -17386300.832972415, 3867401.5930082975, -661831.8578823695, 81795.22327472153, -6496.800216671602, 248.9756331794938 },
        { -34.9236866551736, 1008.3499844777587, -14050.51766067738, 125814.76297678592, -813330.3539071339, 4042617.9073167704, -16066705.905124787, 52421507.100955725, -143056791.4635932, 330996041.9962811, -655859437.4111028, 1121213560.1396055, -1662566882.5892467, 2146214149.676577, -2417264475.4618125, 2377409977.5232906, -2040888180.0447514, 1526490596.323561, -991557993.0575042, 556603586.5184374, -268124096.45567676, 109772016.49156506, -37692327.615818575, 10656653.85517493, -2416503.5045752446, 422587.29957451223, -53498.19209542658, 4362.544820906308, -171.99338376066447 },
        { 16.81599092824591, -486.2663902495178, 6786.7641207051265, -60878.163102203565, 394288.72867680684, -1963777.5344699402, 7821883.422604145, -25581785.359901823, 69993789.5220796, -162408660.75005186, 322814835.468615, -553766495.2576306, 824279482.6381627, -1068596540.4381391, 1209293020.9273002, -1195749695.8178701, 1032755066.6657892, -777841990.3436697, 509322550.9773111, -288575917.94210225, 140534344.41360444, -58281341.14471058, 20320902.34660462, -5851337.768088875, 1356108.951769052, -243347.52778392963, 31747.21242355117, -2679.301367302161, 109.76019583088662 },
        { -7.221603153966283, 209.0873979792874, -2922.1226176434916, 26249.643434735426, -170275.32546025168, 849494.2853832232, -3389789.3284914964, 11108516.943291739, -30459942.663116857, 70845992.2965263, -141189488.72941747, 242907894.18064144, -362743515.08970296, 471975046.21896136, -536313803.22341603, 532785673.5368674, -462624999.44356185, 350594252.2394069, -231227204.55079946, 132132125.66331086, -65007549.643687755, 27295764.400185525, -9663800.845852742, 2836373.484505023, -673416.7967528369, 124576.45324825475, -16879.358501118637, 1491.3711464228102, -64.4613228406614 },
        { 2.7123555635786865, -78.61061604542044, 1099.8285989784208, -9891.449164988893, 64244.99821514092, -320955.98090852523, 1282648.123101393, -4210176.517599593, 11565139.029471038, -26952127.239278313, 53830322.921154924, -92836592.40183796, 139012875.75750208, -181426425.2681507, 206873385.91375872, -206328117.93275362, 179978627.0263245, -137124222.96711338, 91009476.0094056, -52400878.65199307, 26019309.009291824, -11051060.6702535, 3970011.6435558414, -1187652.552950719, 289295.85214968986, -55429.264247160776, 7878.417013215966, -741.3987399466729, 34.66370918037696 },
        { -0.8619303321856188, 25.001009446958946, -350.0892726320243, 3151.526563835273, -20489.959455776538, 102476.84703203871, -410023.88791670284, 1347634.5661237556, -3707225.127107439, 8653307.819145005, -17313401.378812466, 29917769.45009119, -44897702.20369258, 58742646.158505134, -67172614.25042714, 67214845.38021424, -58853986.17586312, 45040819.45045862, -30052988.298548013, 17415574.576698117, -8716748.98556241, 3739777.0330306557, -1361312.033197028, 414594.62560185377, -103596.50475746868, 20627.81255134799, -3113.1606815364307, 320.6224288550022, -16.952229549633163 },
        { 0.2168273819131646, -6.2931797282415785, 88.18258604017566, -794.4009202708387, 5168.9319875295, -25873.5520574725, 103620.0284502236, -340917.5884199616, 938886.681262, -2194242.051722286, 4396252.966419512, -7608475.418809525, 11437842.377134228, -14994262.698597766, 17184500.87900859, -17239804.39815338, 15140914.10761893, -11628639.477347335, 7792286.10750458, -4539206.8441756535, 2286781.776103092, -989340.9306187722, 364154.61283655517, -112637.2958887255, 28801.796489313467, -5955.6426572274, 965.4509980553119, -113.99274415115505, 7.470066235712212 },
        { -0.03571426867119646, 1.0370365592917963, -14.538455064586019, 131.03994353681398, -853.124644009695, 4273.04175069638, -17124.538746125178, 56382.83574938272, -155405.19294031514, 363520.92366948834, -729061.417306247, 1263186.643459214, -1901359.0885627307, 2496143.249982975, -2865470.611505391, 2880165.3791676704, -2535145.611319583, 1952197.724961775, -1312310.7175084169, 767433.1831526227, -388513.05686759244, 169148.54531814632, -62789.9916626932, 19655.99782327753, -5118.749547531394, 1091.9999280147715, -188.99999177338108, 27.999999399360465, -2.92717101798882 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_29d[30][30] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.961654060781723, 29.000007554223505, -203.00010469720954, 1218.000933217883, -5937.7560086494395, 23751.029770470854, -79170.11803280193, 222968.9559176446, -536519.1735071159, 1112780.7602960998, -2003005.815062984, 3145216.437378842, -4324673.541369065, 5220317.110275379, -5539929.536683798, 5170601.983128271, -4241510.317454993, 3052713.9335894934, -1922079.5299917075, 1054215.5762674748, -500752.4974975597, 204388.81435134087, -70944.89131286298, 20653.14820159545, -4948.151010242335, 950.0451715898789, -140.53925205983904, 15.037124346220446, -1.035720483213147, 0.03448297033895143 },
        { 7.663343718843674, -119.91082010654654, 1049.626053247919, -6718.25815927816, 33776.486078798676, -137565.90391849863, 464019.6264826111, -1317827.848244964, 3190869.700037194, -6650116.097131112, 12016312.48699101, -18927821.994132422, 26093626.271353837, -31566955.656288214, 33562685.87002446, -31376182.372115836, 25774888.04287509, -18574036.243870106, 11707777.119700804, -6427826.509655179, 3055947.842453543, -1248333.9260957001, 433624.1609123669, -126319.20522030222, 30282.550092317793, -5817.530591263174, 861.0294723701825, -92.17099725770585, 6.351351516516542, -0.2115479781483346 },
        { -17.66600332514733, 343.0411841550776, -3438.2415867007276, 23606.65719028604, -123165.08375931677, 513115.55663948803, -1757309.237076599, 5045577.079531283, -12317593.799710006, 25835882.963795178, -46923429.648274876, 74223381.17202309, -102681796.11531423, 124588394.45165308, -132801869.95380193, 124423797.8066485, -102408671.5941458, 73923845.93461755, -46666916.466773815, 25655837.141488105, -12212278.258909239, 4994131.038743984, -1736511.1906361629, 506326.503648985, -121483.64447591502, 23356.030176034536, -3459.2950234490568, 370.552895741135, -25.549827550654822, 0.8514874944335765 },
        { 36.758469440072076, -807.9936947304184, 8859.007224364077, -64524.3012052541, 349571.37552250107, -1493081.654954547, 5203631.967661717, -15134244.070752144, 37312705.31007912, -78873852.45573872, 144155890.7992355, -229212576.70922378, 318480701.1575307, -387861764.24325025, 414753096.82099915, -389668041.1617408, 321504229.7447059, -232579399.04915974, 147106041.86037955, -81013252.95949933, 38622599.581988595, -15816720.733642865, 5506695.388224109, -1607508.8071303507, 386107.2002687781, -74305.26883442771, 11015.544841587105, -1180.965692014471, 81.49251160066574, -2.717861344144254 },
        { -69.67538158477217, 1658.0111741225487, -19360.12050827983, 147834.57082293744, -828959.911540636, 3630339.1307409164, -12889543.824013282, 38023817.06815623, -94796205.167973, 202188740.1335296, -372259653.6607225, 595542034.2407545, -831779922.2841045, 1017492735.9958903, -1092231743.1908178, 1029629068.3097358, -852041230.5180581, 618000730.5507119, -391805736.1414584, 216229949.34850347, -103283872.02131051, 42370395.35590665, -14774949.15479011, 4319359.004829903, -1038852.6515331562, 200170.8294610525, -29708.609993233873, 3188.402579066392, -220.23237108197873, 7.351730936781009 },
        { 121.12750752753757, -3043.173580803673, 37204.375272475714, -294960.5695087797, 1704186.1168705705, -7641339.115533617, 27640014.49469757, -82756085.23564538, 208810646.21214214, -449789933.4807074, 834987454.2586329, -1345163233.2477882, 1890003474.740607, -2323948271.848803, 2505911718.492933, -2371662503.124484, 1969511296.0656579, -1433007347.094094, 911071571.6105596, -504081443.7672776, 241333659.94648612, -99210900.98005421, 34662241.0912421, -10151155.346712215, 2445431.0674909726, -471904.5267555557, 70135.83544466122, -7536.895561717062, 521.223458069023, -17.41892596501075 },
        { -194.11318266550532, 5070.249465538638, -64162.247723696186, 524130.4955138191, -3106287.0223272853, 14228785.927679772, -52392615.46218402, 159213946.14087987, -406761022.0074593, 885447168.972616, -1658535008.6451051, 2692567889.836532, -3808533113.985291, 4710431919.00531, -5105486960.949925, 4854101095.391896, -4047490584.1045256, 2955738732.0851407, -1885407199.0941973, 1046295912.6705506, -502292435.2173919, 207005338.0142761, -72489159.68368323, 21273918.936663467, -5134915.218472299, 992694.6193905999, -147784.73495284744, 15905.973587644196, -1101.6024224765863, 36.86504704261716 },
        { 287.86757623639676, -7738.991289742288, 100565.20061256234, -841456.2093919602, 5094907.8637657575, -23782912.1545681, 89029929.28022042, -274460945.84412056, 709988266.5706018, -1562360346.7390795, 2954275404.4817696, -4836098796.670443, 6890675475.510887, -8577871557.435305, 9351134718.232206, -8936815280.857367, 7486558743.054635, -5490238965.535535, 3515533374.744382, -1957739841.6044486, 942851049.6962845, -389709437.07984483, 136837560.90369534, -40259070.08515031, 9739892.794997003, -1886992.5361823696, 281484.08365498215, -30352.653830391526, 2105.820318663299, -70.58686991000248 },
        { -396.2128314576779, 10887.816866523557, -144448.55872180927, 1232332.2145649258, -7596915.262582469, 36051121.83500858, -136989810.32451713, 428051688.7967305, -1120810325.8406796, 2493321143.479718, -4760686625.198177, 7861336300.493921, -11289095697.462868, 14152540016.998152, -15526743203.583105, 14924532013.680649, -12568247578.824026, 9261013259.137596, -5956033932.103697, 3330150737.5524764, -1609744063.6274383, 667631032.1882278, -235165123.58932304, 69391276.50109178, -16833729.72949397, 3269652.2568891817, -488897.96563143743, 52835.832934537844, -3673.3399499933366, 123.3722021619937 },
        { 507.2398925837645, -14178.076348518558, 191224.93231578913, -1657410.647745142, 10372538.05771712, -49928913.70204538, 192274927.0337969, -608321849.0956852, 1611281630.7502303, -3622655993.4442444, 6984771826.683555, -11637508150.787464, 16849136477.877073, -21281860687.6586, 23509411511.634224, -22740709989.487705, 19261937597.854836, -14269470664.594044, 9222586155.350288, -5180188297.71813, 2514666109.889132, -1047060250.520365, 370170695.9402876, -109602721.65338922, 26673951.57345342, -5196501.555308958, 779201.7692194069, -84432.3954106566, 5884.687002459485, -198.10691792342595 },
        { -604.9663099418547, 17138.372893049436, -234233.48436298408, 2056713.9311708594, -13035410.789361766, 63520674.72587313, -247519633.50332326, 791994835.8470341, -2120422985.475262, 4816023072.662207, -9374902314.656908, 15760520986.90249, -23010856579.335533, 29293241154.09631, -32596638005.178562, 31746281073.245132, -27061128826.926147, 20166243002.162518, -13105980073.643326, 7399529035.605128, -3609403965.613756, 1509698371.5337183, -535995956.1971322, 159334330.25309756, -38922487.628483735, 7609470.549094529, -1144816.57921499, 124439.13147313058, -8698.784799945755, 293.66576952707857 },
        { 672.8743013682895, -19268.167168262156, 266189.9852109295, -2362512.7126343665, 15133816.930528272, -74525968.40539968, 293423628.02866095, -948426958.8500308, 2564386404.5874543, -5880229066.844023, 11552265340.99077, -19593126791.52183, 28848857500.86469, -37021280075.5523, 41511619088.68248, -40722031024.36497, 34950512847.258156, -26214481911.654797, 17141125298.895655, -9733753620.632713, 4773966881.928795, -2007110390.5329738, 716073228.3193628, -213848252.7079638, 52467509.13797215, -10300018.38867601, 1555679.1580143562, -169728.4918307085, 11906.63178266223, -403.31140659198434 },
        { -698.3343845581863, 20171.88576636507, -281141.36153670767, 2517532.249541153, -16272235.432271115, 80857777.96001054, -321239128.8868432, 1047719784.4856317, -2858284118.4325867, 6612310262.638594, -13103980224.280312, 22415134343.519054, -33279585781.535446, 43053680908.15711, -48654838659.20955, 48091012389.49625, -41575935045.07856, 31401991152.887905, -20670726732.274868, 11813310611.528818, -5829381138.83779, 2465168052.301228, -884401727.9749553, 265524149.3021361, -65477056.83721983, 12916246.24204387, -1959847.2304809485, 214768.22046500878, -15129.734306171316, 514.5512976144108 },
        { 676.3346894458467, -19675.612576936575, 276225.356247493, -2491959.876732767, 16229537.115667101, -81270630.85984232, 325421415.97180563, -1069826046.6674044, 2942105858.7466707, -6861423506.543174, 13708281165.180674, -23639431102.851498, 35381193816.34643, -46139461012.36415, 52554621789.723366, -52349637695.57893, 45602392324.86269, -34699251353.83347, 23006465442.299274, -13240527680.240845, 6578093565.449891, -2800078310.0526857, 1010928590.1086615, -305368028.5228695, 75746020.813765, -15026658.621115863, 2292505.5428968426, -252539.6873867438, 17880.297808035302, -611.0426377220016 },
        { -611.0429388254622, 17880.30578533706, -252539.78907206867, 2292506.3714463385, -15026663.456893893, 75746042.29267423, -305368103.7679374, 1010928802.5588135, -2800078799.391504, 6578094487.050467, -13240529086.18465, 23006467118.573677, -34699252745.60152, 45602392680.93986, -52349636433.24522, 52554618858.74533, -46139456987.15013, 35381189618.41549, -23639427555.752415, 13708278676.173853, -6861422043.291383, 2942105137.3164988, -1069825749.815042, 325421315.0420074, -81270602.960952, 16229530.99622336, -2491958.8508510753, 276225.2326576937, -19675.603037841378, 676.3343346123678 },
        { 514.551526435888, -15129.740241808831, 214768.2942968211, -1959847.8148290627, 12916249.531659668, -65477070.79185022, 265524195.26368028, -884401846.8678685, 2465168291.65233, -5829381493.891309, 11813310918.152527, -20670726567.30097, 31401989868.852478, -41575932014.637024, 48091007384.82314, -48654832113.70197, 43053673832.22757, -33279579336.16352, 22415129355.43372, -13103976934.446682, 6612308415.637266, -2858283239.805812, 1047719433.1134627, -321239012.17785865, 80857746.32203743, -16272228.60683644, 2517531.1216506558, -281141.2273697299, 20171.875528817658, -698.3340077425512 },
        { -403.3115606703207, 11906.635651412429, -169728.53806754222, 1555679.505755107, -10300020.214713024, 52467516.14460568, -213848272.33199227, 716073265.4310808, -2007110417.9742668, 4773966772.507415, -9733753058.287256, 17141123735.711191, -26214478683.65933, 34950507475.07967, -40722023571.60022, 41511610322.985115, -37021271256.64292, 28848849875.33938, -19593121118.900562, 11552261714.420736, -5880227081.291679, 2564385479.5009456, -948426595.2991692, 293423509.060768, -74525936.56835024, 15133810.139438508, -2362511.6016515703, 266189.85425053234, -19268.157258677522, 672.8739394844423 },
        { 293.665859714159, -8698.786942084225, 124439.15521954985, -1144816.7391778384, 7609471.247146699, -38922489.45341093, 159334330.9513883, -535995937.02039176, 1509698260.2374601, -3609403569.6389914, 7399527974.225384, -13105977775.66855, 20166238861.675545, -27061122509.23243, 31746272822.251255, -32596628723.301426, 29293232130.61119, -23010848986.53347, 15760515462.628279, -9374898847.684183, 4816021203.852769, -2120422126.389733, 791994502.1328664, -247519525.40571457, 63520646.0581798, -13035404.723626714, 2056712.9460857436, -234233.36902225608, 17138.364220081236, -604.9659951147238 },
        { -198.10696206569705, 5884.687938652631, -84432.4039986796, 779201.8076904084, -5196501.558133969, 26673950.38766314, -109602712.13979593, 370170649.20964277, -1047060079.7497399, 2514665612.9764814, -5180187109.605876, 9222583767.758698, -14269466582.417725, 19261931608.05044, -22740702400.15571, 23509403178.10318, -21281852745.02916, 16849129904.00101, -11637503434.400455, 6984768902.333996, -3622654433.5222473, 1611280920.258601, -608321575.3466511, 192274839.00406808, -49928890.5098226, 10372533.179816842, -1657409.8598902684, 191224.84053851242, -14178.069480561711, 507.239644438362 },
        { 123.37221849606136, -3673.340194187964, 52835.83335957984, -488897.9437831559, 3269651.950909672, -16833727.407702032, 69391264.05238026, -235165072.48526388, 667630863.6906197, -1609743605.3025622, 3330149692.493157, -5956031905.170963, 9261009887.223125, -12568242738.702215, 14924525990.221067, -15526736687.754406, 14152533885.274826, -11289090677.487795, 7861332732.998158, -4760684431.746953, 2493319982.033301, -1120809800.3503408, 428051487.5291934, -136989745.95025316, 36051104.958718054, -7596911.729138652, 1232331.6462398155, -144448.49277876478, 10887.811950271958, -396.21265447953147 },
        { -70.58687267460436, 2105.8202587629876, -30352.65118508625, 281484.04437023477, -1886992.1816048708, 9739890.5454446, -40259059.17334811, 136837518.92695576, -389709304.7541636, 942850701.5952907, -1957739067.945331, 3515531904.5825768, -5490236559.971128, 7486555337.621548, -8936811092.172724, 9351130232.321037, -8577867372.583278, 6890672075.418352, -4836096396.620681, 2954273937.8136144, -1562359574.2943997, 709987918.8045706, -274460813.2383365, 89029887.03931685, -23782901.122579742, 5094905.562018156, -841455.8403713567, 100565.15792739732, -7738.988116786951, 287.8674623466925 },
        { 36.865045065046, -1101.6022873760926, 15905.970709415038, -147784.7005963419, 992694.3416174825, -5134913.5694389045, 21273911.289017465, -72489131.2307653, 207005250.51035908, -502292209.5124035, 1046295418.8717858, -1885406272.9551382, 2955737233.0504975, -4047488481.8634977, 4854098530.4847145, -5105484233.329344, 4710429390.24158, -3808531070.7320285, 2692566454.6766324, -1658534135.6181583, 885446711.0194068, -406760816.6011151, 159213868.08300906, -52392590.67490941, 14228779.473004347, -3106285.679266923, 524130.28073648765, -64162.22294092973, 5070.2476276183825, -194.11311684881846 },
        { -17.41892347294017, 521.2233468949952, -7536.893521679925, 70135.81293786688, -471904.35359407414, 2445430.073979651, -10151150.852630544, 34662224.70616083, -99210851.35446836, 241333533.564928, -504081170.13619316, 911071062.9760325, -1433006529.9765694, 1969510157.7664478, -2371661122.3641176, 2505910257.6429014, -2323946923.691933, 1890002389.8772638, -1345162474.0738528, 834986994.0516145, -449789692.8067345, 208810538.57266706, -82756044.43753667, 27640001.570717834, -7641335.757797373, 1704185.4196998002, -294960.45824184234, 37204.362458608884, -3043.1726322614372, 121.12747362322033 },
        { 7.351729271552007, -220.23230547376025, 3188.401450505352, -29708.598031304642, 200170.73994062966, -1038852.148240408, 4319356.763125718, -14774941.090964291, 42370371.17897493, -103283810.98556028, 216229818.15004227, -391805493.81265944, 618000343.3243824, -852040693.7097026, 1029628419.9439434, -1092231059.8194096, 1017492107.4998219, -831779418.091862, 595541682.4047436, -372259440.95447415, 202188629.15149882, -94796155.64252205, 38023798.334728606, -12889537.900927756, 3630337.5946339904, -828959.5931330718, 147834.52008561845, -19360.114674268953, 1658.010742891251, -69.67536619407471 },
        { -2.7178605239308915, 81.4924810968261, -1180.965185598851, 11015.53959981352, -74305.23027476956, 386106.9863009527, -1607507.863762677, 5506692.026655995, -15816710.724959662, 38622574.47050362, -81013199.25814007, 147105943.1306059, -232579241.89333916, 321504012.66735494, -389667779.808486, 414752822.1401548, -387861512.2720977, 318480499.4939185, -229212436.28501666, 144155806.08193722, -78873808.33120035, 37312685.65341788, -15134236.647127444, 5203629.623964912, -1493081.0479763432, 349571.2498726536, -64524.28120802768, 8859.004927814536, -807.9935251714577, 36.758463395712944 },
        { 0.8514871818423941, -25.54981629059437, 370.55271283647653, -3459.293158782981, 23356.016613348518, -121483.56987414612, 506326.17701242457, -1736510.0345971952, 4994127.6135267075, -12212269.703221114, 25655818.912419032, -46666883.06658423, 73923792.91769572, -102408598.55895217, 124423710.08406113, -132801777.95379095, 124588310.22189513, -102681728.8215852, 74223334.38917497, -46923401.469926335, 25835868.306753248, -12317587.27883023, 5045574.619802803, -1757308.4614142836, 513115.35596800764, -123165.04226101587, 23606.650592139355, -3438.2408296730705, 343.04112831186023, -17.666001336341935 },
        { -0.21154788908737768, 6.351348369139929, -92.17094684650039, 861.0289635687183, -5817.526918468366, 30282.53000990143, -126319.11770984938, 433623.85270263965, -1248333.0160118823, 3055945.5763748656, -6427821.694139616, 11707768.318249231, -18574022.301084086, 25774868.873190384, -31376159.38753024, 33562661.80229187, -31566933.652886476, 26093608.715130918, -18927809.803558856, 12016305.153252935, -6650112.286210209, 3190868.0062231217, -1317827.2099050828, 464019.42536050524, -137565.85192692062, 33776.475335384035, -6718.25645233257, 1049.6258575464801, -119.91080568003167, 7.663343205424632 },
        { 0.03448295440643962, -1.0357199266704755, 15.037115512000456, -140.5391634747035, 950.0445353131993, -4948.147544776862, 20653.133148501773, -70944.8384741962, 204388.65868664562, -500752.1107333026, 1054214.7558503281, -1922078.0330565067, 3052711.565473376, -4241507.066015929, 5170598.089365648, -5539925.463864948, 5220313.390528092, -4324670.576153689, 3145214.3801359357, -2003004.5785126402, 1112780.1181737715, -536518.8883035664, 222968.8485036827, -79170.08421081168, 23751.02103202247, -5937.7542039504615, 1218.0006466298062, -203.00007185689975, 29.000005134490877, -2.961653974711247 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };

    const double bezier_standard_fitting_matrix_30d[31][31] = {
        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { -2.9949873739726054, 30.000007218939547, -217.50010363658646, 1353.3342908745271, -6851.256399442221, 28501.23295840658, -98962.6360298965, 290829.0334140116, -731616.9408274012, 1589686.521509083, -3004508.136823067, 4966130.142888814, -7207787.528149024, 9212321.942641705, -10387365.02308937, 10341200.933062501, -9088947.854966803, 7044722.155276431, -4805197.191566464, 2875132.375739417, -1502256.950596396, 681295.798352625, -266043.2450087246, 88513.4598917407, -24740.746219313387, 5700.269066843899, -1054.0440536791928, 150.371198271155, -15.53580325419684, 1.0344889035649814, -0.03333353885786166 },
        { 7.852550043309191, -125.89579708221191, 1137.7448423795204, -7545.96981910649, 39382.73169212025, -166780.6025531473, 585924.4463120984, -1736227.3243579727, 4394727.93531555, -9594721.041899292, 18203095.5009644, -30181173.82410642, 43917603.43583727, -56253564.72174921, 63546859.22111563, -63366324.233199164, 55771421.6613355, -43281269.83036388, 29554595.632597197, -17701032.80830191, 9256970.601939602, -4201529.520076614, 1641871.638327731, -546617.9940076598, 152880.0817189852, -35243.23378732478, 6520.226510500816, -930.6265689212225, 96.19145643013327, -6.4077758000300795, 0.2065520925747394 },
        { -18.37494728964318, 366.03412638742435, -3783.1590055155893, 26882.144369543243, -145500.76678378048, 630033.9875514915, -2246739.8194330954, 6729399.859985165, -17171382.514970273, 37725541.77073469, -71934130.7025699, 119761313.35305497, -174868785.88628313, 224640408.60994604, -254399318.53824434, 254226117.20156947, -224179506.56978178, 174264981.78110236, -119173735.36665758, 71471301.73213944, -37421555.852411926, 17003204.92981988, -6651050.789744114, 2216284.5822218647, -620369.6301454556, 143121.46621858323, -26496.94428424894, 3784.33985494709, -391.39264458358485, 26.087167170947804, -0.8413495085952473 },
        { 38.873030528081735, -877.4024338473859, 9915.904546747186, -74679.11539909679, 419405.75902645406, -1860901.8672645446, 6750522.790698861, -20475278.6063826, 52752784.787443, -116783069.17707027, 224053582.35160834, -374920027.5693869, 549774387.8931319, -708817147.9394084, 805225853.3061304, -806865551.7741836, 713201353.8876888, -555574654.4938573, 380652898.9165043, -228671606.86596864, 119911941.34043038, -54559401.6072079, 21368485.897871833, -7128645.578796045, 1997510.719755736, -461279.73848437826, 85476.04793472431, -12217.97821404388, 1264.6111100210405, -84.34969588333914, 2.7222293908525135 },
        { -75.03328788761975, 1834.8199799818076, -22081.53096449834, 174256.52475627197, -1012256.5917988884, 4602569.828581548, -17001386.3508073, 52285801.870859176, -136179732.83485246, 304112215.0680597, -587638771.1380659, 989204680.714748, -1457882888.358509, 1887770442.281065, -2152574311.752672, 2164027400.418362, -1918344450.551838, 1498198998.9588888, -1028847142.691838, 619338883.6616544, -325377156.7835349, 148295729.19781807, -58170504.17651905, 19433446.850972526, -5452506.192394358, 1260642.3887580936, -233858.7229921871, 33462.27187237273, -3466.80120830287, 231.4426516720378, -7.475621463365279 },
        { 133.03698728541926, -3436.8461119831495, 43308.22767247368, -354730.6596547602, 2122199.4198841103, -9874408.78322167, 37142193.89284512, -115886233.49115479, 305369705.2099164, -688508478.7235417, 1341087034.5234885, -2272828690.9463553, 3369092537.159296, -4384389006.031787, 5021242326.8460245, -5067356228.301332, 4507353970.484459, -3530871616.1267943, 2431340324.5608397, -1467203630.323762, 772532760.3130981, -352809373.2187007, 138650266.21987575, -46398943.850113116, 13038767.136533778, -3018997.0492692515, 560800.9391575479, -80344.05804252272, 8333.61550641134, -556.9558136141819, 18.008075370546738 },
        { -217.77858526426732, 5852.224946856661, -76344.17017706552, 644212.4462641667, -3952028.26066536, 18777342.591257744, -71867187.1428333, 227488603.70170644, -606723567.3414991, 1381942748.9062977, -2715165544.753477, 4635913307.497485, -6916410669.866413, 9051560855.186872, -10417899101.93263, 10559928587.735683, -9429879229.48076, 7413043466.380962, -5120836271.506016, 3099110250.1719007, -1636074466.0024223, 748976256.882049, -294988169.84815425, 98917290.70745611, -27849264.197479986, 6459414.568924027, -1201818.7937276184, 172439.11744197423, -17911.171227188996, 1198.6175833889624, -38.80262374967742 },
        { 330.42577282030095, -9143.03721658777, 122499.92982953734, -1058748.6426078994, 6634263.535941391, -32111981.966611147, 124900587.05618054, -400913502.58156765, 1082233694.8901675, -2490938837.711495, 4938844436.526439, -8500169206.797399, 12770917833.083164, -16817624461.78254, 19463693700.356796, -19827043493.9112, 17784390652.554554, -14037157040.07454, 9732220675.83598, -5909571210.462069, 3129296971.3428483, -1436574528.0729272, 567264064.994797, -190672615.7947955, 53800876.90083923, -12504327.125034405, 2330969.5936109363, -335049.34205381264, 34859.60678279969, -2336.465828826104, 75.74936691928673 },
        { -466.06443272927976, 13187.108176126885, -180421.23334723577, 1589953.7039086733, -10142266.521697162, 49895259.47257787, -196932748.63074073, 640486146.0236884, -1749356103.2087152, 4068816534.710521, -8143071916.28313, 14132435632.211832, -21392466531.782227, 28361150171.084923, -33023136637.044086, 33824772802.954803, -30491668628.073116, 24176583990.54772, -16831880513.131462, 10259652505.988144, -5451895032.015365, 2510935370.5203743, -994476620.6007935, 335201359.1660229, -94826708.06028059, 22092739.2227485, -4127671.234545396, 594558.0273093721, -61982.39224608184, 4162.114684889411, -135.17463328420524 },
        { 612.5149316471975, -17634.235592643712, 245320.8402752769, -2196494.4017275563, 14223344.480146011, -70964649.37707661, 283788972.9587743, -934235149.4301751, 2580323351.630359, -6063313903.854287, 12248873114.831585, -21440681357.449696, 32709499828.53838, -43675333581.829506, 51187838824.59695, -52745208809.07947, 47809810194.47089, -38100311538.520615, 26649783834.03933, -16314294425.6408, 8704027976.779188, -4023663579.381836, 1599124476.6340668, -540746739.5366148, 153436104.8880723, -35848573.097151645, 6715477.702255135, -969719.7947262485, 101329.78902433651, -6819.326683779986, 221.93606430278152 },
        { -751.3017682342869, 21928.85656039969, -309192.8219717549, 2804814.190968634, -18393697.15619519, 92894593.61114815, -375828839.83158946, 1250962995.2975001, -3491335778.9974184, 8284886147.935916, -16891244224.27698, 29821446245.162827, -45860011354.59668, 61691476448.94691, -72804439447.96169, 75503217998.86444, -68848736463.51271, 55172743866.29538, -38791997142.10151, 23862622787.33498, -12788904500.177904, 5937058562.175205, -2368932080.7255564, 804041852.9181002, -228943984.0912136, 53666211.45584954, -10084422.499326143, 1460459.8438679902, -153031.14099130977, 10325.686138445866, -336.883954982276 },
        { 861.08697456196, -25411.443281478103, 362238.95877801464, -3321807.5207743095, 22017906.784192167, -112368786.58512847, 459288199.9378662, -1544018389.934685, 4350793373.167644, -10420150084.33878, 21433365170.22261, -38161191708.33153, 59157697396.966705, -80187211751.90648, 95315207673.32303, -99522362844.30495, 91334583596.36383, -73635790333.16882, 52069228664.53732, -32202542844.426983, 17346245189.12121, -8091320279.729838, 3243102373.813385, -1105448816.7248032, 316038886.2747679, -74365215.91490842, 14024595.538029952, -2038065.4866041727, 214250.5217160326, -14501.203455345447, 474.5071363010008 },
        { -922.8376361275187, 27477.984819814523, -395234.199028681, 3657236.511989104, -24461151.269079603, 125967482.4549686, -519499602.5808402, 1761975764.8146727, -5008511576.261131, 12098661697.758516, -25095344599.639183, 45047192842.5435, -70387039235.92447, 96140428225.65942, -115122480059.09851, 121056779952.7231, -111852557077.95905, 90764018113.42584, -64579340957.94841, 40176019621.60362, -21763410393.422573, 10206352451.68186, -4111794614.5959477, 1408393485.9503353, -404520701.1322857, 95607149.82149288, -18106799.88243248, 2641896.375694074, -278795.6654912213, 18939.101737068348, -621.8967538131491 },
        { 925.0734510334314, -27746.60880506659, 402077.3319461911, -3748771.06776574, 25266092.889149748, -131123983.61690813, 545004470.1427555, -1863052049.5705388, 5337677789.761183, -12995604590.028812, 27167676485.560562, -49147274569.82491, 77384956410.15463, -106500064994.69553, 128475637028.51831, -136079828064.14468, 126623296507.80396, -103456353429.86288, 74100447688.01346, -46396246832.16616, 25289190661.861046, -11930907851.79317, 4834291400.022238, -1665056079.8066387, 480790729.70449954, -114215686.1992519, 21737499.437825732, -3186630.609289525, 337807.14806035155, -23047.891232726448, 759.9842046099538 },
        { -867.2565867205736, 26169.775154409712, -381582.45076194045, 3580349.4109713114, -24288431.084160402, 126891635.98507161, -531008552.7761876, 1827820774.312731, -5273744647.349092, 12931994985.070774, -27230778220.97447, 49621817440.940056, -78706850125.56998, 109117616807.05403, -132601888223.89029, 141478383527.0367, -132601882984.98378, 109117608203.68513, -78706840843.58133, 49621809671.0303, -27230772920.551167, 12931991984.801598, -5273743231.460455, 1827820218.797128, -531008373.13914055, 126891588.85061081, -24288421.288537066, 3580347.8576229326, -381582.27416327584, 26169.762330761176, -867.2561395122655 },
        { 759.9845278593891, -23047.90034802427, 337807.27104444976, -3186631.6643198025, 21737505.884693157, -114215716.01509427, 480790837.61519116, -1665056391.069269, 4834292119.033428, -11930909162.545483, 25289192445.879112, -46396248270.493484, 74100447047.38748, -103456348444.22462, 126623285432.94275, -136079810871.46971, 128475615871.6763, -106500043452.7908, 77384937906.93385, -49147261055.24694, 27167668069.023064, -12995600126.734774, 5337675783.8527565, -1863051291.7246885, 545004232.3261857, -131123922.71732277, 25266080.483102985, -3748769.133057044, 402077.115029346, -27746.593237705547, 925.0729134972182 },
        { -621.8969481826356, 18939.107038839527, -278795.733996261, 2641896.9310971904, -18106803.01980835, 95607162.78971283, -404520740.45171326, 1408393567.8846033, -4111794692.210178, 10206352240.30026, -21763409081.263638, 40176015620.2733, -64579332013.12799, 90764002068.69847, -111852533115.12509, 121056749599.18556, -115122447117.11592, 96140397436.76137, -70387014382.48956, 45047175523.44096, -25095334202.1396, 12098656343.36668, -5008509226.681866, 1761974894.44863, -519499333.9202365, 125967414.60982515, -24461137.61101554, 3657234.403602905, -395233.96468946914, 27477.968127586104, -922.8370634521209 },
        { 474.5072221424105, -14501.205585858652, 214250.545550199, -2038065.6388878657, 14024596.052655382, -74365215.7995455, 316038873.5317443, -1105448728.9836314, 3243101990.4435368, -8091319009.61331, 17346241802.14271, -32202535349.48859, 52069214639.79174, -73635767893.0178, 91334552651.2492, -99522325887.0336, 95315169333.42741, -80187177170.44995, 59157670270.449165, -38161173244.57028, 21433354300.00388, -10420144577.824493, 4350790990.370556, -1544017517.7279656, 459287933.45775, -112368719.88699095, 22017893.46040877, -3321805.4778101984, 362238.73303812346, -25411.427283676083, 861.0864281461688 },
        { -336.8839667496462, 10325.686146799677, -153031.13561390125, 1460459.7396511724, -10084421.397740085, 53666203.579105906, -228943941.84375635, 804041674.17452, -2368931466.4222965, 5937056805.312883, -12788900260.019615, 23862614056.93537, -38791981671.65241, 55172720143.26542, -68848704841.13707, 75503181264.48418, -72804402203.31755, 61691443496.00565, -45859985922.27128, 29821429173.776688, -16891234293.276703, 8284881169.097041, -3491333643.9411054, 1250962219.9041696, -375828604.55859584, 92894535.08087811, -18393685.526471853, 2804812.416149747, -309192.6266722481, 21928.842770247287, -751.301298728008 },
        { 221.93603758480555, -6819.325636407765, 101329.76988983175, -969719.5779165858, 6715475.954076854, -35848562.48503002, 153436054.0003406, -540746541.0367692, 1599123835.175282, -4023661831.20373, 8704023917.527782, -16314286327.087347, 26649769852.961678, -38100290564.41138, 47809782750.012436, -52745177430.613365, 51187807443.14383, -43675306145.449104, 32709478870.9633, -21440667416.6089, 12248865069.180159, -6063309898.482756, 2580321644.723854, -934234532.9295055, 283788786.80817014, -70964603.26830344, 14223335.353903117, -2196493.013735749, 245320.6880045016, -17634.224869727743, 612.5145674381946 },
        { -135.1745954467582, 4162.113388857346, -61982.37085031699, 594557.8028663846, -4127669.5324278525, 22092729.383777983, -94826662.73503499, 335201188.12875766, -994476083.121672, 2510933939.9699287, -5451891776.89954, 10259646124.090101, -16831869660.601187, 24176567923.385994, -30491647844.955334, 33824749280.87303, -33023113323.07158, 28361129950.580544, -21392451193.969116, 14132425493.32676, -8143066097.362548, 4068813652.342377, -1749354880.4108644, 640485706.1338423, -196932616.28179905, 49895226.79563947, -10142260.072639357, 1589952.725597687, -180421.12626500012, 13187.100650827531, -466.0641775938007 },
        { 75.74933368564238, -2336.4647355358106, 34859.589360233345, -335049.1648441202, 2330968.2849123147, -12504319.734492317, 53800843.54010632, -190672492.11851048, 567263682.4251041, -1436573523.8518062, 3129294714.213591, -5909566833.26299, 9732213303.90704, -14037146220.466711, 17784376764.825848, -19827027884.72901, 19463678325.679436, -16817611202.726366, 12770907825.715607, -8500162621.302217, 4938840672.24709, -2490936979.971121, 1082232909.427403, -400913220.85926867, 124900502.52291438, -32111961.14629297, 6634259.435939939, -1058748.0218613653, 122499.86200332279, -9143.032457611927, 330.4256117029347 },
        { -38.802600764553524, 1198.6168414664053, -17911.159609098555, 172439.00120915804, -1201817.9476205038, 6459409.854735959, -27849243.173127037, 98917213.60681787, -294987933.7209082, 748975642.6112782, -1636073096.5004976, 3099107613.8184867, -5120831860.601592, 7413037031.773592, -9429871015.006727, 10559919400.71801, -10417890093.820398, 9051553119.163305, -6916404852.361541, 4635909491.929706, -2715163370.336143, 1381941678.786366, -606723116.053589, 227488442.20382637, -71867138.78396712, 18777330.70308208, -3952025.9236287535, 644212.0929690647, -76344.1316262955, 5852.222245358687, -217.7784939074367 },
        { 18.008062099652506, -556.9553898140177, 8333.608936813675, -80343.99298623875, 560800.4697037248, -3018994.456230047, 13038755.662220027, -46398902.073575154, 138650139.14052716, -352809044.6778278, 772532031.9686029, -1467202235.517186, 2431338001.7757993, -3530868242.5313377, 4507349680.751776, -5067351448.147381, 5021237655.550689, -4384385007.154147, 3369089538.2289567, -2272826728.924502, 1341085918.9522915, -688507930.8864315, 305369474.6393664, -115886151.12241867, 37142169.26788159, -9874402.73856319, 2122198.2332049417, -354730.48047399445, 43308.20814137606, -3436.844744682205, 133.03694108959448 },
        { -7.475614964788573, 231.44244551623484, -3466.7980328356934, 33462.24064229097, -233858.4988981927, 1260641.1582962146, -5452500.776551208, 19433427.231521726, -58170444.783275425, 148295576.3332816, -325376819.27456266, 619338239.7749165, -1028846074.055445, 1498197451.9391062, -1918342489.2098126, 2164025220.796397, -2152572187.1946077, 1887768628.0167782, -1457881530.5946968, 989203794.0862334, -587638267.8917365, 304111968.34746116, -136179629.15893057, 52285764.88343205, -17001375.30686628, 4602567.120804582, -1012256.0607832032, 174256.44465079662, -22081.522240079437, 1834.8193697069182, -75.03326728414923 },
        { 2.722226704187202, -84.3496110234802, 1264.6098083775482, -12217.965474424525, 85475.95686401016, -461279.2405321477, 1997508.536255294, -7128637.697426093, 21368462.122610427, -54559340.617038436, 119911807.08229588, -228671351.45703107, 380652476.08119154, -555574043.8724946, 713200581.4426969, -806864695.1238933, 805225019.920153, -708816437.6332098, 549773857.157297, -374919681.4895819, 224053386.1781987, -116782973.12779105, 52752744.47542128, -20475264.23951566, 6750518.505130063, -1860900.8174879854, 419405.55333238374, -74679.08439203702, 9915.901171906295, -877.402197928545, 38.873022568060996 },
        { -0.8413485932998662, 26.08713834561883, -391.3922036896245, 3784.335554749786, -26496.913622359858, 143121.29907419803, -620368.899185954, 2216281.9507659446, -6651042.872133232, 17003184.668786563, -37421511.34971756, 71471217.25003725, -119173595.76192592, 174264780.54707903, -224179252.42873344, 254225835.79051158, -254399045.1737466, 224640175.9637871, -174868612.26478657, 119761200.25967169, -71934066.66031986, 37725510.44675742, -17171369.380723033, 6729395.182737986, -2246738.4252823503, 630033.6462916356, -145500.69996146526, 26882.134302201343, -3783.157910321767, 366.0340498668648, -18.374944709058386 },
        { 0.20655185079096028, -6.407768200777697, 96.1913404194471, -930.6254402405451, 6520.218476616385, -35243.190087625415, 152879.89097337774, -546617.3086306768, 1641869.5800405862, -4201524.262447083, 9256959.072186196, -17701010.954669937, 29554559.568222452, -43281217.91568261, 55771356.17798348, -63366251.80564811, 63546788.94187288, -56253504.97817427, 43917558.88995296, -30181144.83057717, 18203079.094711423, -9594713.023586752, 4394724.575620137, -1736226.1286367634, 585924.090104616, -166780.5154086169, 39382.7146368988, -7545.967250696036, 1137.7445630745935, -125.89577757505567, 7.852549385698389 },
        { -0.033333497744739225, 1.0344876130970984, -15.535783578683287, 150.37100717326044, -1054.0426950176616, 5700.261687465618, -24740.714050670686, 88513.344457484, -266042.898800106, 681294.9151236826, -1502255.0158630903, 2875128.7126174374, -4805191.1520334445, 7044713.4696432995, -9088936.908646354, 10341188.835579269, -10387353.293558734, 9212311.979561191, -7207780.104229383, 4966125.313530322, -3004505.4055046863, 1589685.1873601943, -731616.3821014535, 290828.8346450603, -98962.57684020793, 28501.218483635115, -6851.253567580764, 1353.3338645449608, -217.50005728709934, 30.000003982740125, -2.9949872649065896 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
    };



    typedef Interval(*estimate_univariate_polynomial_interval_nd_func)(double* polynomial, const Interval& t);

    Interval estimate_univariate_polynomial_interval_0d(double* polynomial, const Interval& t) {
        return polynomial[0];
    }

    Interval estimate_univariate_polynomial_interval_1d(double* polynomial, const Interval& t) {
        double s[2] = {
            calculate_univariate_polynomial_value(1, polynomial, t.Min),
            calculate_univariate_polynomial_value(1, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[1]) {
            result = Interval(s[0], s[1]);
        }
        else {
            result = Interval(s[1], s[0]);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_2d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[3] = {
            calculate_univariate_polynomial_value(2, polynomial, t.Min),
            calculate_univariate_polynomial_value(2, polynomial, 1.0 / 2 * tlen + t.Min),
            calculate_univariate_polynomial_value(2, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[2]) {
            result = Interval(s[0], s[2]);
        }
        else {
            result = Interval(s[2], s[0]);
        }
        for (int i = 1; i < 2; ++i) {
            double p = 0;
            for (int j = 0; j <= 2; ++j) {
                p += bezier_standard_fitting_matrix_2d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_3d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[4] = {
            calculate_univariate_polynomial_value(3, polynomial, t.Min),
            calculate_univariate_polynomial_value(3, polynomial, 1.0 / 3 * tlen + t.Min),
            calculate_univariate_polynomial_value(3, polynomial, 2.0 / 3 * tlen + t.Min),
            calculate_univariate_polynomial_value(3, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[3]) {
            result = Interval(s[0], s[3]);
        }
        else {
            result = Interval(s[3], s[0]);
        }
        for (int i = 1; i < 3; ++i) {
            double p = 0;
            for (int j = 0; j <= 3; ++j) {
                p += bezier_standard_fitting_matrix_3d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_4d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[5] = {
            calculate_univariate_polynomial_value(4, polynomial, t.Min),
            calculate_univariate_polynomial_value(4, polynomial, 1.0 / 4 * tlen + t.Min),
            calculate_univariate_polynomial_value(4, polynomial, 2.0 / 4 * tlen + t.Min),
            calculate_univariate_polynomial_value(4, polynomial, 3.0 / 4 * tlen + t.Min),
            calculate_univariate_polynomial_value(4, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[4]) {
            result = Interval(s[0], s[4]);
        }
        else {
            result = Interval(s[4], s[0]);
        }
        for (int i = 1; i < 4; ++i) {
            double p = 0;
            for (int j = 0; j <= 4; ++j) {
                p += bezier_standard_fitting_matrix_4d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_5d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[6] = {
            calculate_univariate_polynomial_value(5, polynomial, t.Min),
            calculate_univariate_polynomial_value(5, polynomial, 1.0 / 5 * tlen + t.Min),
            calculate_univariate_polynomial_value(5, polynomial, 2.0 / 5 * tlen + t.Min),
            calculate_univariate_polynomial_value(5, polynomial, 3.0 / 5 * tlen + t.Min),
            calculate_univariate_polynomial_value(5, polynomial, 4.0 / 5 * tlen + t.Min),
            calculate_univariate_polynomial_value(5, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[5]) {
            result = Interval(s[0], s[5]);
        }
        else {
            result = Interval(s[5], s[0]);
        }
        for (int i = 1; i < 5; ++i) {
            double p = 0;
            for (int j = 0; j <= 5; ++j) {
                p += bezier_standard_fitting_matrix_5d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_6d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[7] = {
            calculate_univariate_polynomial_value(6, polynomial, t.Min),
            calculate_univariate_polynomial_value(6, polynomial, 1.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, polynomial, 2.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, polynomial, 3.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, polynomial, 4.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, polynomial, 5.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[6]) {
            result = Interval(s[0], s[6]);
        }
        else {
            result = Interval(s[6], s[0]);
        }
        for (int i = 1; i < 6; ++i) {
            double p = 0;
            for (int j = 0; j <= 6; ++j) {
                p += bezier_standard_fitting_matrix_6d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_7d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[8] = {
            calculate_univariate_polynomial_value(7, polynomial, t.Min),
            calculate_univariate_polynomial_value(7, polynomial, 1.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, polynomial, 2.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, polynomial, 3.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, polynomial, 4.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, polynomial, 5.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, polynomial, 6.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[7]) {
            result = Interval(s[0], s[7]);
        }
        else {
            result = Interval(s[7], s[0]);
        }
        for (int i = 1; i < 7; ++i) {
            double p = 0;
            for (int j = 0; j <= 7; ++j) {
                p += bezier_standard_fitting_matrix_7d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_8d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[9] = {
            calculate_univariate_polynomial_value(8, polynomial, t.Min),
            calculate_univariate_polynomial_value(8, polynomial, 1.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, polynomial, 2.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, polynomial, 3.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, polynomial, 4.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, polynomial, 5.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, polynomial, 6.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, polynomial, 7.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[8]) {
            result = Interval(s[0], s[8]);
        }
        else {
            result = Interval(s[8], s[0]);
        }
        for (int i = 1; i < 8; ++i) {
            double p = 0;
            for (int j = 0; j <= 8; ++j) {
                p += bezier_standard_fitting_matrix_8d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_9d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[10] = {
            calculate_univariate_polynomial_value(9, polynomial, t.Min),
            calculate_univariate_polynomial_value(9, polynomial, 1.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, polynomial, 2.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, polynomial, 3.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, polynomial, 4.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, polynomial, 5.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, polynomial, 6.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, polynomial, 7.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, polynomial, 8.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[9]) {
            result = Interval(s[0], s[9]);
        }
        else {
            result = Interval(s[9], s[0]);
        }
        for (int i = 1; i < 9; ++i) {
            double p = 0;
            for (int j = 0; j <= 9; ++j) {
                p += bezier_standard_fitting_matrix_9d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_10d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[11] = {
            calculate_univariate_polynomial_value(10, polynomial, t.Min),
            calculate_univariate_polynomial_value(10, polynomial, 1.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, polynomial, 2.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, polynomial, 3.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, polynomial, 4.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, polynomial, 5.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, polynomial, 6.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, polynomial, 7.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, polynomial, 8.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, polynomial, 9.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[10]) {
            result = Interval(s[0], s[10]);
        }
        else {
            result = Interval(s[10], s[0]);
        }
        for (int i = 1; i < 10; ++i) {
            double p = 0;
            for (int j = 0; j <= 10; ++j) {
                p += bezier_standard_fitting_matrix_10d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_11d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[12] = {
            calculate_univariate_polynomial_value(11, polynomial, t.Min),
            calculate_univariate_polynomial_value(11, polynomial, 1.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, polynomial, 2.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, polynomial, 3.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, polynomial, 4.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, polynomial, 5.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, polynomial, 6.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, polynomial, 7.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, polynomial, 8.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, polynomial, 9.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, polynomial, 10.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[11]) {
            result = Interval(s[0], s[11]);
        }
        else {
            result = Interval(s[11], s[0]);
        }
        for (int i = 1; i < 11; ++i) {
            double p = 0;
            for (int j = 0; j <= 11; ++j) {
                p += bezier_standard_fitting_matrix_11d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_12d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[13] = {
            calculate_univariate_polynomial_value(12, polynomial, t.Min),
            calculate_univariate_polynomial_value(12, polynomial, 1.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, polynomial, 2.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, polynomial, 3.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, polynomial, 4.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, polynomial, 5.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, polynomial, 6.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, polynomial, 7.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, polynomial, 8.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, polynomial, 9.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, polynomial, 10.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, polynomial, 11.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[12]) {
            result = Interval(s[0], s[12]);
        }
        else {
            result = Interval(s[12], s[0]);
        }
        for (int i = 1; i < 12; ++i) {
            double p = 0;
            for (int j = 0; j <= 12; ++j) {
                p += bezier_standard_fitting_matrix_12d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_13d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[14] = {
            calculate_univariate_polynomial_value(13, polynomial, t.Min),
            calculate_univariate_polynomial_value(13, polynomial, 1.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, polynomial, 2.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, polynomial, 3.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, polynomial, 4.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, polynomial, 5.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, polynomial, 6.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, polynomial, 7.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, polynomial, 8.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, polynomial, 9.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, polynomial, 10.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, polynomial, 11.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, polynomial, 12.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[13]) {
            result = Interval(s[0], s[13]);
        }
        else {
            result = Interval(s[13], s[0]);
        }
        for (int i = 1; i < 13; ++i) {
            double p = 0;
            for (int j = 0; j <= 13; ++j) {
                p += bezier_standard_fitting_matrix_13d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_14d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[15] = {
            calculate_univariate_polynomial_value(14, polynomial, t.Min),
            calculate_univariate_polynomial_value(14, polynomial, 1.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, polynomial, 2.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, polynomial, 3.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, polynomial, 4.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, polynomial, 5.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, polynomial, 6.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, polynomial, 7.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, polynomial, 8.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, polynomial, 9.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, polynomial, 10.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, polynomial, 11.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, polynomial, 12.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, polynomial, 13.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[14]) {
            result = Interval(s[0], s[14]);
        }
        else {
            result = Interval(s[14], s[0]);
        }
        for (int i = 1; i < 14; ++i) {
            double p = 0;
            for (int j = 0; j <= 14; ++j) {
                p += bezier_standard_fitting_matrix_14d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_15d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[16] = {
            calculate_univariate_polynomial_value(15, polynomial, t.Min),
            calculate_univariate_polynomial_value(15, polynomial, 1.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, polynomial, 2.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, polynomial, 3.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, polynomial, 4.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, polynomial, 5.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, polynomial, 6.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, polynomial, 7.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, polynomial, 8.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, polynomial, 9.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, polynomial, 10.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, polynomial, 11.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, polynomial, 12.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, polynomial, 13.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, polynomial, 14.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[15]) {
            result = Interval(s[0], s[15]);
        }
        else {
            result = Interval(s[15], s[0]);
        }
        for (int i = 1; i < 15; ++i) {
            double p = 0;
            for (int j = 0; j <= 15; ++j) {
                p += bezier_standard_fitting_matrix_15d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_16d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[17] = {
            calculate_univariate_polynomial_value(16, polynomial, t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 1.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 2.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 3.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 4.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 5.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 6.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 7.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 8.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 9.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 10.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 11.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 12.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 13.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 14.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, 15.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[16]) {
            result = Interval(s[0], s[16]);
        }
        else {
            result = Interval(s[16], s[0]);
        }
        for (int i = 1; i < 16; ++i) {
            double p = 0;
            for (int j = 0; j <= 16; ++j) {
                p += bezier_standard_fitting_matrix_16d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_17d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[18] = {
            calculate_univariate_polynomial_value(17, polynomial, t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 1.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 2.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 3.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 4.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 5.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 6.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 7.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 8.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 9.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 10.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 11.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 12.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 13.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 14.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 15.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, 16.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[17]) {
            result = Interval(s[0], s[17]);
        }
        else {
            result = Interval(s[17], s[0]);
        }
        for (int i = 1; i < 17; ++i) {
            double p = 0;
            for (int j = 0; j <= 17; ++j) {
                p += bezier_standard_fitting_matrix_17d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_18d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[19] = {
            calculate_univariate_polynomial_value(18, polynomial, t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 1.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 2.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 3.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 4.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 5.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 6.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 7.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 8.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 9.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 10.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 11.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 12.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 13.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 14.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 15.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 16.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, 17.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[18]) {
            result = Interval(s[0], s[18]);
        }
        else {
            result = Interval(s[18], s[0]);
        }
        for (int i = 1; i < 18; ++i) {
            double p = 0;
            for (int j = 0; j <= 18; ++j) {
                p += bezier_standard_fitting_matrix_18d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_19d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[20] = {
            calculate_univariate_polynomial_value(19, polynomial, t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 1.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 2.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 3.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 4.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 5.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 6.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 7.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 8.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 9.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 10.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 11.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 12.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 13.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 14.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 15.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 16.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 17.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, 18.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[19]) {
            result = Interval(s[0], s[19]);
        }
        else {
            result = Interval(s[19], s[0]);
        }
        for (int i = 1; i < 19; ++i) {
            double p = 0;
            for (int j = 0; j <= 19; ++j) {
                p += bezier_standard_fitting_matrix_19d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_20d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[21] = {
            calculate_univariate_polynomial_value(20, polynomial, t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 1.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 2.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 3.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 4.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 5.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 6.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 7.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 8.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 9.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 10.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 11.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 12.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 13.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 14.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 15.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 16.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 17.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 18.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, 19.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[20]) {
            result = Interval(s[0], s[20]);
        }
        else {
            result = Interval(s[20], s[0]);
        }
        for (int i = 1; i < 20; ++i) {
            double p = 0;
            for (int j = 0; j <= 20; ++j) {
                p += bezier_standard_fitting_matrix_20d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_21d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[22] = {
            calculate_univariate_polynomial_value(21, polynomial, t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 1.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 2.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 3.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 4.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 5.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 6.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 7.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 8.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 9.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 10.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 11.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 12.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 13.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 14.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 15.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 16.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 17.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 18.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 19.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, 20.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[21]) {
            result = Interval(s[0], s[21]);
        }
        else {
            result = Interval(s[21], s[0]);
        }
        for (int i = 1; i < 21; ++i) {
            double p = 0;
            for (int j = 0; j <= 21; ++j) {
                p += bezier_standard_fitting_matrix_21d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_22d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[23] = {
            calculate_univariate_polynomial_value(22, polynomial, t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 1.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 2.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 3.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 4.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 5.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 6.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 7.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 8.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 9.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 10.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 11.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 12.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 13.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 14.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 15.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 16.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 17.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 18.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 19.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 20.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, 21.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[22]) {
            result = Interval(s[0], s[22]);
        }
        else {
            result = Interval(s[22], s[0]);
        }
        for (int i = 1; i < 22; ++i) {
            double p = 0;
            for (int j = 0; j <= 22; ++j) {
                p += bezier_standard_fitting_matrix_22d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_23d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[24] = {
            calculate_univariate_polynomial_value(23, polynomial, t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 1.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 2.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 3.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 4.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 5.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 6.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 7.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 8.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 9.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 10.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 11.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 12.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 13.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 14.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 15.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 16.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 17.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 18.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 19.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 20.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 21.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, 22.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[23]) {
            result = Interval(s[0], s[23]);
        }
        else {
            result = Interval(s[23], s[0]);
        }
        for (int i = 1; i < 23; ++i) {
            double p = 0;
            for (int j = 0; j <= 23; ++j) {
                p += bezier_standard_fitting_matrix_23d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_24d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[25] = {
            calculate_univariate_polynomial_value(24, polynomial, t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 1.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 2.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 3.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 4.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 5.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 6.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 7.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 8.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 9.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 10.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 11.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 12.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 13.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 14.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 15.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 16.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 17.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 18.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 19.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 20.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 21.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 22.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, 23.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[24]) {
            result = Interval(s[0], s[24]);
        }
        else {
            result = Interval(s[24], s[0]);
        }
        for (int i = 1; i < 24; ++i) {
            double p = 0;
            for (int j = 0; j <= 24; ++j) {
                p += bezier_standard_fitting_matrix_24d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_25d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[26] = {
            calculate_univariate_polynomial_value(25, polynomial, t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 1.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 2.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 3.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 4.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 5.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 6.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 7.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 8.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 9.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 10.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 11.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 12.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 13.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 14.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 15.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 16.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 17.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 18.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 19.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 20.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 21.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 22.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 23.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, 24.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[25]) {
            result = Interval(s[0], s[25]);
        }
        else {
            result = Interval(s[25], s[0]);
        }
        for (int i = 1; i < 25; ++i) {
            double p = 0;
            for (int j = 0; j <= 25; ++j) {
                p += bezier_standard_fitting_matrix_25d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_26d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[27] = {
            calculate_univariate_polynomial_value(26, polynomial, t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 1.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 2.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 3.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 4.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 5.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 6.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 7.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 8.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 9.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 10.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 11.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 12.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 13.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 14.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 15.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 16.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 17.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 18.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 19.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 20.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 21.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 22.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 23.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 24.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, 25.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[26]) {
            result = Interval(s[0], s[26]);
        }
        else {
            result = Interval(s[26], s[0]);
        }
        for (int i = 1; i < 26; ++i) {
            double p = 0;
            for (int j = 0; j <= 26; ++j) {
                p += bezier_standard_fitting_matrix_26d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_27d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[28] = {
            calculate_univariate_polynomial_value(27, polynomial, t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 1.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 2.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 3.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 4.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 5.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 6.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 7.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 8.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 9.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 10.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 11.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 12.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 13.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 14.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 15.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 16.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 17.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 18.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 19.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 20.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 21.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 22.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 23.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 24.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 25.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, 26.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[27]) {
            result = Interval(s[0], s[27]);
        }
        else {
            result = Interval(s[27], s[0]);
        }
        for (int i = 1; i < 27; ++i) {
            double p = 0;
            for (int j = 0; j <= 27; ++j) {
                p += bezier_standard_fitting_matrix_27d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_28d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[29] = {
            calculate_univariate_polynomial_value(28, polynomial, t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 1.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 2.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 3.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 4.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 5.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 6.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 7.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 8.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 9.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 10.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 11.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 12.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 13.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 14.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 15.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 16.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 17.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 18.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 19.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 20.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 21.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 22.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 23.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 24.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 25.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 26.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, 27.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[28]) {
            result = Interval(s[0], s[28]);
        }
        else {
            result = Interval(s[28], s[0]);
        }
        for (int i = 1; i < 28; ++i) {
            double p = 0;
            for (int j = 0; j <= 28; ++j) {
                p += bezier_standard_fitting_matrix_28d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_29d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[30] = {
            calculate_univariate_polynomial_value(29, polynomial, t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 1.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 2.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 3.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 4.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 5.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 6.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 7.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 8.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 9.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 10.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 11.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 12.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 13.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 14.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 15.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 16.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 17.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 18.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 19.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 20.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 21.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 22.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 23.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 24.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 25.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 26.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 27.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, 28.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[29]) {
            result = Interval(s[0], s[29]);
        }
        else {
            result = Interval(s[29], s[0]);
        }
        for (int i = 1; i < 29; ++i) {
            double p = 0;
            for (int j = 0; j <= 29; ++j) {
                p += bezier_standard_fitting_matrix_29d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    Interval estimate_univariate_polynomial_interval_30d(double* polynomial, const Interval& t) {
        double tlen = t.Length();
        double s[31] = {
            calculate_univariate_polynomial_value(30, polynomial, t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 1.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 2.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 3.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 4.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 5.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 6.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 7.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 8.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 9.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 10.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 11.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 12.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 13.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 14.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 15.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 16.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 17.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 18.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 19.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 20.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 21.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 22.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 23.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 24.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 25.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 26.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 27.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 28.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, 29.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, polynomial, t.Max)
        };
        Interval result;
        if (s[0] < s[30]) {
            result = Interval(s[0], s[30]);
        }
        else {
            result = Interval(s[30], s[0]);
        }
        for (int i = 1; i < 30; ++i) {
            double p = 0;
            for (int j = 0; j <= 30; ++j) {
                p += bezier_standard_fitting_matrix_30d[i][j] * s[j];
            }
            result.Merge(p);
        }
        return result;
    }

    const estimate_univariate_polynomial_interval_nd_func estimate_univariate_polynomial_interval_nd_funcs[31] = {
        estimate_univariate_polynomial_interval_0d,
        estimate_univariate_polynomial_interval_1d,
        estimate_univariate_polynomial_interval_2d,
        estimate_univariate_polynomial_interval_3d,
        estimate_univariate_polynomial_interval_4d,
        estimate_univariate_polynomial_interval_5d,
        estimate_univariate_polynomial_interval_6d,
        estimate_univariate_polynomial_interval_7d,
        estimate_univariate_polynomial_interval_8d,
        estimate_univariate_polynomial_interval_9d,
        estimate_univariate_polynomial_interval_10d,
        estimate_univariate_polynomial_interval_11d,
        estimate_univariate_polynomial_interval_12d,
        estimate_univariate_polynomial_interval_13d,
        estimate_univariate_polynomial_interval_14d,
        estimate_univariate_polynomial_interval_15d,
        estimate_univariate_polynomial_interval_16d,
        estimate_univariate_polynomial_interval_17d,
        estimate_univariate_polynomial_interval_18d,
        estimate_univariate_polynomial_interval_19d,
        estimate_univariate_polynomial_interval_20d,
        estimate_univariate_polynomial_interval_21d,
        estimate_univariate_polynomial_interval_22d,
        estimate_univariate_polynomial_interval_23d,
        estimate_univariate_polynomial_interval_24d,
        estimate_univariate_polynomial_interval_25d,
        estimate_univariate_polynomial_interval_26d,
        estimate_univariate_polynomial_interval_27d,
        estimate_univariate_polynomial_interval_28d,
        estimate_univariate_polynomial_interval_29d,
        estimate_univariate_polynomial_interval_30d
    };

    Interval estimate_univariate_polynomial_interval(int degree, double* polynomial, const Interval& t) {
        if (degree > 30) {
            throw "degree is too large";
        }
        return estimate_univariate_polynomial_interval_nd_funcs[degree](polynomial, t);
    }



    typedef Interval(*estimate_univariate_rational_polynomial_interval_nd_func)(double* n_polynomial, double* d_polynomial, const Interval& t);

    Interval estimate_univariate_rational_polynomial_interval_0d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        return Interval(n_polynomial[0]) / Interval(d_polynomial[0]);
    }

    Interval estimate_univariate_rational_polynomial_interval_1d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double n[2] = {
            calculate_univariate_polynomial_value(1, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(1, n_polynomial, t.Max)
        };
        double d[2] = {
            calculate_univariate_polynomial_value(1, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(1, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[1] / d[1];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_2d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[3] = {
            calculate_univariate_polynomial_value(2, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(2, n_polynomial, 1.0 / 2 * tlen + t.Min),
            calculate_univariate_polynomial_value(2, n_polynomial, t.Max)
        };
        double d[3] = {
            calculate_univariate_polynomial_value(2, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(2, d_polynomial, 1.0 / 2 * tlen + t.Min),
            calculate_univariate_polynomial_value(2, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[2] / d[2];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 2; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 2; ++j) {
                wp += bezier_standard_fitting_matrix_2d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_2d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_3d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[4] = {
            calculate_univariate_polynomial_value(3, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(3, n_polynomial, 1.0 / 3 * tlen + t.Min),
            calculate_univariate_polynomial_value(3, n_polynomial, 2.0 / 3 * tlen + t.Min),
            calculate_univariate_polynomial_value(3, n_polynomial, t.Max)
        };
        double d[4] = {
            calculate_univariate_polynomial_value(3, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(3, d_polynomial, 1.0 / 3 * tlen + t.Min),
            calculate_univariate_polynomial_value(3, d_polynomial, 2.0 / 3 * tlen + t.Min),
            calculate_univariate_polynomial_value(3, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[3] / d[3];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 3; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 3; ++j) {
                wp += bezier_standard_fitting_matrix_3d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_3d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_4d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[5] = {
            calculate_univariate_polynomial_value(4, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(4, n_polynomial, 1.0 / 4 * tlen + t.Min),
            calculate_univariate_polynomial_value(4, n_polynomial, 2.0 / 4 * tlen + t.Min),
            calculate_univariate_polynomial_value(4, n_polynomial, 3.0 / 4 * tlen + t.Min),
            calculate_univariate_polynomial_value(4, n_polynomial, t.Max)
        };
        double d[5] = {
            calculate_univariate_polynomial_value(4, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(4, d_polynomial, 1.0 / 4 * tlen + t.Min),
            calculate_univariate_polynomial_value(4, d_polynomial, 2.0 / 4 * tlen + t.Min),
            calculate_univariate_polynomial_value(4, d_polynomial, 3.0 / 4 * tlen + t.Min),
            calculate_univariate_polynomial_value(4, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[4] / d[4];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 4; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 4; ++j) {
                wp += bezier_standard_fitting_matrix_4d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_4d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_5d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[6] = {
            calculate_univariate_polynomial_value(5, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(5, n_polynomial, 1.0 / 5 * tlen + t.Min),
            calculate_univariate_polynomial_value(5, n_polynomial, 2.0 / 5 * tlen + t.Min),
            calculate_univariate_polynomial_value(5, n_polynomial, 3.0 / 5 * tlen + t.Min),
            calculate_univariate_polynomial_value(5, n_polynomial, 4.0 / 5 * tlen + t.Min),
            calculate_univariate_polynomial_value(5, n_polynomial, t.Max)
        };
        double d[6] = {
            calculate_univariate_polynomial_value(5, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(5, d_polynomial, 1.0 / 5 * tlen + t.Min),
            calculate_univariate_polynomial_value(5, d_polynomial, 2.0 / 5 * tlen + t.Min),
            calculate_univariate_polynomial_value(5, d_polynomial, 3.0 / 5 * tlen + t.Min),
            calculate_univariate_polynomial_value(5, d_polynomial, 4.0 / 5 * tlen + t.Min),
            calculate_univariate_polynomial_value(5, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[5] / d[5];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 5; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 5; ++j) {
                wp += bezier_standard_fitting_matrix_5d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_5d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_6d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[7] = {
            calculate_univariate_polynomial_value(6, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(6, n_polynomial, 1.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, n_polynomial, 2.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, n_polynomial, 3.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, n_polynomial, 4.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, n_polynomial, 5.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, n_polynomial, t.Max)
        };
        double d[7] = {
            calculate_univariate_polynomial_value(6, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(6, d_polynomial, 1.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, d_polynomial, 2.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, d_polynomial, 3.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, d_polynomial, 4.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, d_polynomial, 5.0 / 6 * tlen + t.Min),
            calculate_univariate_polynomial_value(6, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[6] / d[6];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 6; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 6; ++j) {
                wp += bezier_standard_fitting_matrix_6d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_6d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_7d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[8] = {
            calculate_univariate_polynomial_value(7, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(7, n_polynomial, 1.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, n_polynomial, 2.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, n_polynomial, 3.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, n_polynomial, 4.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, n_polynomial, 5.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, n_polynomial, 6.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, n_polynomial, t.Max)
        };
        double d[8] = {
            calculate_univariate_polynomial_value(7, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(7, d_polynomial, 1.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, d_polynomial, 2.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, d_polynomial, 3.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, d_polynomial, 4.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, d_polynomial, 5.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, d_polynomial, 6.0 / 7 * tlen + t.Min),
            calculate_univariate_polynomial_value(7, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[7] / d[7];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 7; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 7; ++j) {
                wp += bezier_standard_fitting_matrix_7d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_7d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_8d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[9] = {
            calculate_univariate_polynomial_value(8, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(8, n_polynomial, 1.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, n_polynomial, 2.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, n_polynomial, 3.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, n_polynomial, 4.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, n_polynomial, 5.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, n_polynomial, 6.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, n_polynomial, 7.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, n_polynomial, t.Max)
        };
        double d[9] = {
            calculate_univariate_polynomial_value(8, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(8, d_polynomial, 1.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, d_polynomial, 2.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, d_polynomial, 3.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, d_polynomial, 4.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, d_polynomial, 5.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, d_polynomial, 6.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, d_polynomial, 7.0 / 8 * tlen + t.Min),
            calculate_univariate_polynomial_value(8, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[8] / d[8];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 8; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 8; ++j) {
                wp += bezier_standard_fitting_matrix_8d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_8d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_9d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[10] = {
            calculate_univariate_polynomial_value(9, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(9, n_polynomial, 1.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, n_polynomial, 2.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, n_polynomial, 3.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, n_polynomial, 4.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, n_polynomial, 5.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, n_polynomial, 6.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, n_polynomial, 7.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, n_polynomial, 8.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, n_polynomial, t.Max)
        };
        double d[10] = {
            calculate_univariate_polynomial_value(9, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(9, d_polynomial, 1.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, d_polynomial, 2.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, d_polynomial, 3.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, d_polynomial, 4.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, d_polynomial, 5.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, d_polynomial, 6.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, d_polynomial, 7.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, d_polynomial, 8.0 / 9 * tlen + t.Min),
            calculate_univariate_polynomial_value(9, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[9] / d[9];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 9; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 9; ++j) {
                wp += bezier_standard_fitting_matrix_9d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_9d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_10d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[11] = {
            calculate_univariate_polynomial_value(10, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(10, n_polynomial, 1.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, n_polynomial, 2.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, n_polynomial, 3.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, n_polynomial, 4.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, n_polynomial, 5.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, n_polynomial, 6.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, n_polynomial, 7.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, n_polynomial, 8.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, n_polynomial, 9.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, n_polynomial, t.Max)
        };
        double d[11] = {
            calculate_univariate_polynomial_value(10, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(10, d_polynomial, 1.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, d_polynomial, 2.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, d_polynomial, 3.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, d_polynomial, 4.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, d_polynomial, 5.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, d_polynomial, 6.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, d_polynomial, 7.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, d_polynomial, 8.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, d_polynomial, 9.0 / 10 * tlen + t.Min),
            calculate_univariate_polynomial_value(10, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[10] / d[10];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 10; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 10; ++j) {
                wp += bezier_standard_fitting_matrix_10d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_10d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_11d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[12] = {
            calculate_univariate_polynomial_value(11, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(11, n_polynomial, 1.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, n_polynomial, 2.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, n_polynomial, 3.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, n_polynomial, 4.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, n_polynomial, 5.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, n_polynomial, 6.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, n_polynomial, 7.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, n_polynomial, 8.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, n_polynomial, 9.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, n_polynomial, 10.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, n_polynomial, t.Max)
        };
        double d[12] = {
            calculate_univariate_polynomial_value(11, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(11, d_polynomial, 1.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, d_polynomial, 2.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, d_polynomial, 3.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, d_polynomial, 4.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, d_polynomial, 5.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, d_polynomial, 6.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, d_polynomial, 7.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, d_polynomial, 8.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, d_polynomial, 9.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, d_polynomial, 10.0 / 11 * tlen + t.Min),
            calculate_univariate_polynomial_value(11, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[11] / d[11];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 11; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 11; ++j) {
                wp += bezier_standard_fitting_matrix_11d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_11d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_12d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[13] = {
            calculate_univariate_polynomial_value(12, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(12, n_polynomial, 1.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, n_polynomial, 2.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, n_polynomial, 3.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, n_polynomial, 4.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, n_polynomial, 5.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, n_polynomial, 6.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, n_polynomial, 7.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, n_polynomial, 8.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, n_polynomial, 9.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, n_polynomial, 10.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, n_polynomial, 11.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, n_polynomial, t.Max)
        };
        double d[13] = {
            calculate_univariate_polynomial_value(12, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(12, d_polynomial, 1.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, d_polynomial, 2.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, d_polynomial, 3.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, d_polynomial, 4.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, d_polynomial, 5.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, d_polynomial, 6.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, d_polynomial, 7.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, d_polynomial, 8.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, d_polynomial, 9.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, d_polynomial, 10.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, d_polynomial, 11.0 / 12 * tlen + t.Min),
            calculate_univariate_polynomial_value(12, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[12] / d[12];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 12; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 12; ++j) {
                wp += bezier_standard_fitting_matrix_12d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_12d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_13d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[14] = {
            calculate_univariate_polynomial_value(13, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(13, n_polynomial, 1.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, n_polynomial, 2.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, n_polynomial, 3.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, n_polynomial, 4.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, n_polynomial, 5.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, n_polynomial, 6.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, n_polynomial, 7.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, n_polynomial, 8.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, n_polynomial, 9.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, n_polynomial, 10.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, n_polynomial, 11.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, n_polynomial, 12.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, n_polynomial, t.Max)
        };
        double d[14] = {
            calculate_univariate_polynomial_value(13, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(13, d_polynomial, 1.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, d_polynomial, 2.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, d_polynomial, 3.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, d_polynomial, 4.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, d_polynomial, 5.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, d_polynomial, 6.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, d_polynomial, 7.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, d_polynomial, 8.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, d_polynomial, 9.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, d_polynomial, 10.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, d_polynomial, 11.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, d_polynomial, 12.0 / 13 * tlen + t.Min),
            calculate_univariate_polynomial_value(13, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[13] / d[13];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 13; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 13; ++j) {
                wp += bezier_standard_fitting_matrix_13d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_13d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_14d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[15] = {
            calculate_univariate_polynomial_value(14, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(14, n_polynomial, 1.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, n_polynomial, 2.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, n_polynomial, 3.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, n_polynomial, 4.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, n_polynomial, 5.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, n_polynomial, 6.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, n_polynomial, 7.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, n_polynomial, 8.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, n_polynomial, 9.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, n_polynomial, 10.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, n_polynomial, 11.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, n_polynomial, 12.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, n_polynomial, 13.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, n_polynomial, t.Max)
        };
        double d[15] = {
            calculate_univariate_polynomial_value(14, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(14, d_polynomial, 1.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, d_polynomial, 2.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, d_polynomial, 3.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, d_polynomial, 4.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, d_polynomial, 5.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, d_polynomial, 6.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, d_polynomial, 7.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, d_polynomial, 8.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, d_polynomial, 9.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, d_polynomial, 10.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, d_polynomial, 11.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, d_polynomial, 12.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, d_polynomial, 13.0 / 14 * tlen + t.Min),
            calculate_univariate_polynomial_value(14, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[14] / d[14];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 14; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 14; ++j) {
                wp += bezier_standard_fitting_matrix_14d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_14d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_15d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[16] = {
            calculate_univariate_polynomial_value(15, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, 1.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, 2.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, 3.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, 4.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, 5.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, 6.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, 7.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, 8.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, 9.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, 10.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, 11.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, 12.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, 13.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, 14.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, n_polynomial, t.Max)
        };
        double d[16] = {
            calculate_univariate_polynomial_value(15, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, 1.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, 2.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, 3.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, 4.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, 5.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, 6.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, 7.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, 8.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, 9.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, 10.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, 11.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, 12.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, 13.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, 14.0 / 15 * tlen + t.Min),
            calculate_univariate_polynomial_value(15, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[15] / d[15];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 15; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 15; ++j) {
                wp += bezier_standard_fitting_matrix_15d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_15d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_16d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[17] = {
            calculate_univariate_polynomial_value(16, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 1.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 2.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 3.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 4.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 5.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 6.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 7.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 8.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 9.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 10.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 11.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 12.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 13.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 14.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, 15.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, n_polynomial, t.Max)
        };
        double d[17] = {
            calculate_univariate_polynomial_value(16, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 1.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 2.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 3.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 4.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 5.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 6.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 7.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 8.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 9.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 10.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 11.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 12.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 13.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 14.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, 15.0 / 16 * tlen + t.Min),
            calculate_univariate_polynomial_value(16, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[16] / d[16];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 16; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 16; ++j) {
                wp += bezier_standard_fitting_matrix_16d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_16d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_17d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[18] = {
            calculate_univariate_polynomial_value(17, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 1.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 2.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 3.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 4.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 5.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 6.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 7.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 8.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 9.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 10.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 11.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 12.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 13.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 14.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 15.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, 16.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, n_polynomial, t.Max)
        };
        double d[18] = {
            calculate_univariate_polynomial_value(17, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 1.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 2.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 3.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 4.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 5.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 6.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 7.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 8.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 9.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 10.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 11.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 12.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 13.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 14.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 15.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, 16.0 / 17 * tlen + t.Min),
            calculate_univariate_polynomial_value(17, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[17] / d[17];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 17; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 17; ++j) {
                wp += bezier_standard_fitting_matrix_17d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_17d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_18d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[19] = {
            calculate_univariate_polynomial_value(18, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 1.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 2.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 3.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 4.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 5.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 6.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 7.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 8.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 9.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 10.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 11.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 12.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 13.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 14.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 15.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 16.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, 17.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, n_polynomial, t.Max)
        };
        double d[19] = {
            calculate_univariate_polynomial_value(18, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 1.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 2.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 3.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 4.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 5.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 6.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 7.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 8.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 9.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 10.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 11.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 12.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 13.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 14.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 15.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 16.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, 17.0 / 18 * tlen + t.Min),
            calculate_univariate_polynomial_value(18, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[18] / d[18];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 18; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 18; ++j) {
                wp += bezier_standard_fitting_matrix_18d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_18d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_19d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[20] = {
            calculate_univariate_polynomial_value(19, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 1.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 2.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 3.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 4.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 5.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 6.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 7.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 8.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 9.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 10.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 11.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 12.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 13.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 14.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 15.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 16.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 17.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, 18.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, n_polynomial, t.Max)
        };
        double d[20] = {
            calculate_univariate_polynomial_value(19, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 1.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 2.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 3.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 4.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 5.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 6.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 7.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 8.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 9.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 10.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 11.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 12.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 13.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 14.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 15.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 16.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 17.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, 18.0 / 19 * tlen + t.Min),
            calculate_univariate_polynomial_value(19, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[19] / d[19];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 19; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 19; ++j) {
                wp += bezier_standard_fitting_matrix_19d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_19d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_20d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[21] = {
            calculate_univariate_polynomial_value(20, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 1.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 2.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 3.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 4.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 5.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 6.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 7.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 8.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 9.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 10.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 11.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 12.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 13.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 14.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 15.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 16.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 17.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 18.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, 19.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, n_polynomial, t.Max)
        };
        double d[21] = {
            calculate_univariate_polynomial_value(20, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 1.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 2.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 3.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 4.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 5.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 6.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 7.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 8.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 9.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 10.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 11.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 12.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 13.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 14.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 15.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 16.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 17.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 18.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, 19.0 / 20 * tlen + t.Min),
            calculate_univariate_polynomial_value(20, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[20] / d[20];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 20; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 20; ++j) {
                wp += bezier_standard_fitting_matrix_20d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_20d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_21d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[22] = {
            calculate_univariate_polynomial_value(21, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 1.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 2.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 3.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 4.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 5.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 6.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 7.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 8.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 9.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 10.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 11.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 12.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 13.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 14.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 15.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 16.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 17.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 18.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 19.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, 20.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, n_polynomial, t.Max)
        };
        double d[22] = {
            calculate_univariate_polynomial_value(21, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 1.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 2.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 3.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 4.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 5.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 6.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 7.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 8.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 9.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 10.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 11.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 12.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 13.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 14.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 15.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 16.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 17.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 18.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 19.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, 20.0 / 21 * tlen + t.Min),
            calculate_univariate_polynomial_value(21, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[21] / d[21];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 21; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 21; ++j) {
                wp += bezier_standard_fitting_matrix_21d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_21d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_22d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[23] = {
            calculate_univariate_polynomial_value(22, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 1.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 2.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 3.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 4.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 5.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 6.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 7.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 8.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 9.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 10.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 11.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 12.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 13.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 14.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 15.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 16.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 17.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 18.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 19.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 20.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, 21.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, n_polynomial, t.Max)
        };
        double d[23] = {
            calculate_univariate_polynomial_value(22, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 1.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 2.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 3.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 4.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 5.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 6.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 7.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 8.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 9.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 10.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 11.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 12.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 13.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 14.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 15.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 16.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 17.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 18.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 19.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 20.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, 21.0 / 22 * tlen + t.Min),
            calculate_univariate_polynomial_value(22, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[22] / d[22];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 22; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 22; ++j) {
                wp += bezier_standard_fitting_matrix_22d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_22d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_23d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[24] = {
            calculate_univariate_polynomial_value(23, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 1.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 2.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 3.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 4.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 5.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 6.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 7.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 8.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 9.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 10.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 11.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 12.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 13.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 14.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 15.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 16.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 17.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 18.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 19.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 20.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 21.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, 22.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, n_polynomial, t.Max)
        };
        double d[24] = {
            calculate_univariate_polynomial_value(23, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 1.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 2.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 3.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 4.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 5.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 6.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 7.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 8.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 9.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 10.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 11.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 12.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 13.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 14.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 15.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 16.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 17.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 18.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 19.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 20.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 21.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, 22.0 / 23 * tlen + t.Min),
            calculate_univariate_polynomial_value(23, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[23] / d[23];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 23; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 23; ++j) {
                wp += bezier_standard_fitting_matrix_23d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_23d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_24d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[25] = {
            calculate_univariate_polynomial_value(24, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 1.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 2.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 3.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 4.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 5.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 6.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 7.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 8.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 9.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 10.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 11.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 12.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 13.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 14.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 15.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 16.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 17.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 18.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 19.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 20.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 21.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 22.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, 23.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, n_polynomial, t.Max)
        };
        double d[25] = {
            calculate_univariate_polynomial_value(24, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 1.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 2.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 3.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 4.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 5.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 6.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 7.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 8.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 9.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 10.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 11.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 12.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 13.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 14.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 15.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 16.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 17.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 18.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 19.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 20.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 21.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 22.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, 23.0 / 24 * tlen + t.Min),
            calculate_univariate_polynomial_value(24, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[24] / d[24];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 24; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 24; ++j) {
                wp += bezier_standard_fitting_matrix_24d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_24d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_25d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[26] = {
            calculate_univariate_polynomial_value(25, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 1.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 2.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 3.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 4.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 5.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 6.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 7.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 8.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 9.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 10.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 11.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 12.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 13.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 14.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 15.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 16.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 17.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 18.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 19.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 20.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 21.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 22.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 23.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, 24.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, n_polynomial, t.Max)
        };
        double d[26] = {
            calculate_univariate_polynomial_value(25, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 1.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 2.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 3.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 4.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 5.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 6.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 7.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 8.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 9.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 10.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 11.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 12.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 13.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 14.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 15.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 16.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 17.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 18.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 19.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 20.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 21.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 22.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 23.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, 24.0 / 25 * tlen + t.Min),
            calculate_univariate_polynomial_value(25, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[25] / d[25];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 25; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 25; ++j) {
                wp += bezier_standard_fitting_matrix_25d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_25d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_26d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[27] = {
            calculate_univariate_polynomial_value(26, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 1.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 2.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 3.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 4.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 5.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 6.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 7.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 8.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 9.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 10.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 11.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 12.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 13.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 14.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 15.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 16.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 17.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 18.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 19.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 20.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 21.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 22.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 23.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 24.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, 25.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, n_polynomial, t.Max)
        };
        double d[27] = {
            calculate_univariate_polynomial_value(26, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 1.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 2.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 3.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 4.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 5.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 6.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 7.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 8.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 9.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 10.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 11.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 12.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 13.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 14.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 15.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 16.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 17.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 18.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 19.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 20.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 21.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 22.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 23.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 24.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, 25.0 / 26 * tlen + t.Min),
            calculate_univariate_polynomial_value(26, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[26] / d[26];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 26; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 26; ++j) {
                wp += bezier_standard_fitting_matrix_26d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_26d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_27d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[28] = {
            calculate_univariate_polynomial_value(27, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 1.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 2.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 3.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 4.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 5.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 6.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 7.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 8.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 9.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 10.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 11.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 12.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 13.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 14.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 15.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 16.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 17.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 18.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 19.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 20.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 21.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 22.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 23.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 24.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 25.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, 26.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, n_polynomial, t.Max)
        };
        double d[28] = {
            calculate_univariate_polynomial_value(27, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 1.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 2.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 3.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 4.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 5.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 6.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 7.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 8.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 9.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 10.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 11.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 12.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 13.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 14.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 15.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 16.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 17.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 18.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 19.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 20.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 21.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 22.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 23.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 24.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 25.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, 26.0 / 27 * tlen + t.Min),
            calculate_univariate_polynomial_value(27, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[27] / d[27];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 27; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 27; ++j) {
                wp += bezier_standard_fitting_matrix_27d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_27d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_28d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[29] = {
            calculate_univariate_polynomial_value(28, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 1.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 2.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 3.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 4.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 5.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 6.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 7.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 8.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 9.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 10.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 11.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 12.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 13.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 14.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 15.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 16.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 17.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 18.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 19.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 20.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 21.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 22.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 23.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 24.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 25.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 26.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, 27.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, n_polynomial, t.Max)
        };
        double d[29] = {
            calculate_univariate_polynomial_value(28, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 1.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 2.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 3.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 4.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 5.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 6.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 7.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 8.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 9.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 10.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 11.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 12.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 13.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 14.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 15.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 16.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 17.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 18.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 19.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 20.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 21.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 22.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 23.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 24.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 25.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 26.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, 27.0 / 28 * tlen + t.Min),
            calculate_univariate_polynomial_value(28, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[28] / d[28];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 28; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 28; ++j) {
                wp += bezier_standard_fitting_matrix_28d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_28d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_29d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[30] = {
            calculate_univariate_polynomial_value(29, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 1.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 2.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 3.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 4.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 5.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 6.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 7.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 8.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 9.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 10.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 11.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 12.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 13.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 14.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 15.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 16.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 17.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 18.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 19.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 20.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 21.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 22.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 23.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 24.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 25.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 26.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 27.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, 28.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, n_polynomial, t.Max)
        };
        double d[30] = {
            calculate_univariate_polynomial_value(29, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 1.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 2.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 3.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 4.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 5.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 6.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 7.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 8.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 9.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 10.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 11.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 12.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 13.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 14.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 15.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 16.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 17.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 18.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 19.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 20.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 21.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 22.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 23.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 24.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 25.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 26.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 27.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, 28.0 / 29 * tlen + t.Min),
            calculate_univariate_polynomial_value(29, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[29] / d[29];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 29; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 29; ++j) {
                wp += bezier_standard_fitting_matrix_29d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_29d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    Interval estimate_univariate_rational_polynomial_interval_30d(double* n_polynomial, double* d_polynomial, const Interval& t) {
        double tlen = t.Length();
        double n[31] = {
            calculate_univariate_polynomial_value(30, n_polynomial, t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 1.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 2.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 3.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 4.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 5.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 6.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 7.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 8.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 9.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 10.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 11.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 12.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 13.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 14.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 15.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 16.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 17.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 18.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 19.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 20.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 21.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 22.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 23.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 24.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 25.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 26.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 27.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 28.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, 29.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, n_polynomial, t.Max)
        };
        double d[31] = {
            calculate_univariate_polynomial_value(30, d_polynomial, t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 1.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 2.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 3.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 4.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 5.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 6.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 7.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 8.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 9.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 10.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 11.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 12.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 13.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 14.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 15.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 16.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 17.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 18.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 19.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 20.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 21.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 22.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 23.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 24.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 25.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 26.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 27.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 28.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, 29.0 / 30 * tlen + t.Min),
            calculate_univariate_polynomial_value(30, d_polynomial, t.Max)
        };
        double a = n[0] / d[0];
        double b = n[30] / d[30];
        Interval result;
        if (a < b) {
            result = Interval(a, b);
        }
        else {
            result = Interval(b, a);
        }
        for (int i = 1; i < 30; ++i) {
            double wp = 0;
            double w = 0;
            for (int j = 0; j <= 30; ++j) {
                wp += bezier_standard_fitting_matrix_30d[i][j] * n[j];
                w += bezier_standard_fitting_matrix_30d[i][j] * d[j];
            }
            result.Merge(wp / w);
        }
        return result;
    }

    const estimate_univariate_rational_polynomial_interval_nd_func estimate_univariate_rational_polynomial_interval_nd_funcs[31] = {
        estimate_univariate_rational_polynomial_interval_0d,
        estimate_univariate_rational_polynomial_interval_1d,
        estimate_univariate_rational_polynomial_interval_2d,
        estimate_univariate_rational_polynomial_interval_3d,
        estimate_univariate_rational_polynomial_interval_4d,
        estimate_univariate_rational_polynomial_interval_5d,
        estimate_univariate_rational_polynomial_interval_6d,
        estimate_univariate_rational_polynomial_interval_7d,
        estimate_univariate_rational_polynomial_interval_8d,
        estimate_univariate_rational_polynomial_interval_9d,
        estimate_univariate_rational_polynomial_interval_10d,
        estimate_univariate_rational_polynomial_interval_11d,
        estimate_univariate_rational_polynomial_interval_12d,
        estimate_univariate_rational_polynomial_interval_13d,
        estimate_univariate_rational_polynomial_interval_14d,
        estimate_univariate_rational_polynomial_interval_15d,
        estimate_univariate_rational_polynomial_interval_16d,
        estimate_univariate_rational_polynomial_interval_17d,
        estimate_univariate_rational_polynomial_interval_18d,
        estimate_univariate_rational_polynomial_interval_19d,
        estimate_univariate_rational_polynomial_interval_20d,
        estimate_univariate_rational_polynomial_interval_21d,
        estimate_univariate_rational_polynomial_interval_22d,
        estimate_univariate_rational_polynomial_interval_23d,
        estimate_univariate_rational_polynomial_interval_24d,
        estimate_univariate_rational_polynomial_interval_25d,
        estimate_univariate_rational_polynomial_interval_26d,
        estimate_univariate_rational_polynomial_interval_27d,
        estimate_univariate_rational_polynomial_interval_28d,
        estimate_univariate_rational_polynomial_interval_29d,
        estimate_univariate_rational_polynomial_interval_30d
    };

    Interval estimate_univariate_rational_polynomial_interval(int degree, double* n_polynomial, double* d_polynomial, const Interval& t) {
        if (degree > 30) {
            throw "degree is too large";
        }
        return estimate_univariate_rational_polynomial_interval_nd_funcs[degree](n_polynomial, d_polynomial, t);
    }



}

*/